[DarkRP Server] How to activate Hungermod when there is a cook

Hello, I have a problem with my darkrp 2.4.3 server. How to activate the hungermod when there is a cook and desactivate when there isn’t a cook ?
Thank you for the answer, bye. :wink:


Check if there is a cook
If not, disable ( if there is a function, use that, if there isn’t, figure something out )
If yes, do nothing

there is a job cook.
sorry i don’t understand

Use the Team Changed hook; if someone joins cook job then activate, when player leaves ( or disconnects ) then deactivate.

yes but where i write it ?

Serverside, but you’ll need to network that hunger mode is active to clients if you want the client to predict hunger levels without needing a constant update from the server.


-snip -

Hud etc isn’t done, but this is just a basic cached toggle for a var based on team join, disconnect, sync on connect, etc system:

By the way:

DarkRP Help Thread ( ALL DarkRP Questions go here ): http://forum.facepunch.com/showthread.php?t=1249475

EDIT: Just updated both files to include hud, a quick print of the value, reduced repetitive code to helper functions, etc etc…

thanks for the answer :smile: but i delete all in my server and client file or i just past your notepad ?

It isn’t a complete hunger-system. It only manages one part of it… To toggle a variable on/off based on if players join the team, leave the team, disconnect, sync on connect etc…

Learn from it; copying and pasting won’t help… Read through it and try to understand why I did what when where and how…

You could write it in fewer lines using a timer to count players on the team every second or so; but it would be wasted time as there are hooks that run at specific points. We know the team count will only change if a player disconnects and is in the team, a player switches to the team, a player switches from the team. Additionally, we know that we need to tell inbound clients of the changes, clients on server receive the updates while in the server.

etc etc…

What hunger-mod did you make; show us what you’ve done to give you a better idea of what to do… The code may even be shorter if networking is already in for specific points, etc…

Isnt there a setting to enable hungermod in the config.lua?

GO to darkrpmodification/darkrp config Should find disabled_defaults in there enable hungermod and enable cook.

ok thanks

[editline]7th July 2014[/editline]

it isn’t it

Can you be a little more specific? Are you saying you dont want people to get hungry unless theres a cook? If so, a simple if then statement might be good. Also maybe making a npc in which you can buy food from is better.

no i don’t won’t an npc just if there is a cook then the hungermod is activate you understand ?

[editline]7th July 2014[/editline]

i have already see that in a server but i has closed

Okay. Doing a if then statment is most likely the solution. Please link the hunger mod addon so I can see what needs to be in the statement. Also, posting in the following link might help. http://forum.facepunch.com/showthread.php?t=1249475

There is no hungermod addon to be linked it comes with DarkRP most of the time.

[editline]7th July 2014[/editline]

This is a custom job. You can visit the Hire a coder thread and ask people. It will cost money though I reccomend just Placing an NPC cook in the map which you can buy from Coderhire. ITs called NPC buyers I think have a look into it

ok thanks for all guys if you have more answer, i take it !

I take it the only answer you want is a completed script? I showed how to enable / disable a var based on team. That var only needed to be pasted into the hunger-mod where it adds hunger, takes health, etc… It was essentially done…

This may be of more help:

General Learning Lua Help Thread: http://forum.facepunch.com/showthread.php?t=1337945

Problems that don’t need their own thread ( All simple questions / quickies should go here ): http://forum.facepunch.com/showthread.php?t=1348923

DarkRP Help Thread ( ALL DarkRP Questions go here ): http://forum.facepunch.com/showthread.php?t=1249475

Looking to HIRE a coder? Read this: http://forum.facepunch.com/showthread.php?t=1257110

Coderhire Thread: http://forum.facepunch.com/showthread.php?t=1281665

Facepunch Style Fixer for GreaseMonkey: https://userstyles.org/styles/65192/facepunch-fixer

Thanks guy, yes i would like a script bit i don’t find it but with your links, i think i can do it

This is not helpful but imagine just going afk as a cook and wait for people to die from starving :v:

yes buy they can demote.