Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //====================
- //Hunger Part
- //====================
- //Register Events
- registerOutputEvent(GameConnection,"setFood", "int 1 100 50");
- registerOutputEvent(GameConnection,"addFood", "int 1 100 50");
- registerOutputEvent(GameConnection,"setHunger", "int 1 100 50");
- //Main CMD's
- package HungerMain
- {
- function serverCmdCheckFood(%client)
- {
- if(isObject(%client.player))
- {
- if(%client.food > 1)
- {
- messageClient(%client,'',"\c6You have \c3" @ %client.food @ "\c6 food.");
- }
- else
- {
- messageClient(%client,'',"\c6You have \c3no\c6 food!");
- }
- }
- else
- {
- messageClient(%client,'',"\c6Please wait until you spawn.");
- }
- }
- function serverCmdEatFood(%client, %input)
- {
- if(isObject(%client.player))
- {
- if(%client.food > 5)
- {
- %changefood = %client.food - %input;
- %client.food = %changefood;
- %addfoodvar = %client.hunger + %input;
- %v = (%addfoodvar >= $HungerMod::pref::MaxHunger);
- if(%v $= 1)
- {
- %client.hunger = $HungerMod::pref::MaxHunger;
- }
- else
- {
- %client.hunger = %addfoodvar;
- }
- messageClient(%client,'',"\c6Current Hunger: \c3" @ %client.hunger);
- }
- else
- {
- messageClient(%client,'',"\c6You don't have that much food!");
- }
- }
- else
- {
- messageClient(%client,'',"\c6Please wait until you spawn.");
- }
- }
- function serverCmdStartHunger(%client)
- {
- if(%client.isSuperAdmin || %client.isHost || %client.isAdmin)
- {
- messageAll('',"\c6Hunger\c2 Started.");
- $HungerMod::pref::HungerActive = true;
- HungerTick();
- }
- else
- {
- messageClient(%client,'',"\c6You're not an admin!");
- }
- }
- function serverCmdStopHunger(%client)
- {
- if(%client.isSuperAdmin || %client.isHost || %client.isAdmin)
- {
- messageAll('',"\c6Hunger\c2 Stopped.");
- $HungerMod::pref::HungerActive = false;
- }
- else
- {
- messageClient(%client,'',"\c6You're not an admin!");
- }
- }
- };
- activatePackage(HungerMain);
- //Looping system
- function HungerTick()
- {
- if($HungerMod::pref::HungerActive)
- {
- deductHunger();
- schedule($HungerMod::pref::TickTime,0,HungerTick);
- }
- }
- function deductHunger()
- {
- %count = clientGroup.getCount();
- for(%i=0;%i<%count;%i++)
- {
- %client = clientGroup.getObject(%i);
- if(isObject(%client.player))
- {
- %hungeredit = %client.hunger;
- %client.hunger = %hungeredit - $HungerMod::pref::HungerDecriment;
- if(%client.hunger <= 0)
- {
- %client.player.kill();
- %replacehunger = $HungerMod::pref::MaxHunger / 2;
- %client.hunger = %replacehunger;
- messageAll('',"\c3" @ %client.name @ " \c6has died of hunger.");
- messageClient(%client,'',"\c6Hunger reset to\c3 " @ %replacehunger);
- }
- else
- {
- messageClient(%client,'',"\c6Hunger status:\c3 " @ %client.hunger @ "\c6/\c3" @ $HungerMod::pref::MaxHunger);
- }
- if($HungerMod::pref::Hydration)
- {
- %hydrationedit = %client.hydration;
- %client.hydration = %hydrationedit - $HungerMod::pref::HydrationDecriment;
- if(%client.hydration <= 0)
- {
- %client.player.kill();
- %replacehydration = $HungerMod::pref::MaxHydration / 2;
- %client.hydration = %replacehunger;
- messageAll('',"\c3" @ %client.name @ " \c6has died of hydration.");
- messageClient(%client,'',"\c6Hydration reset to\c3 " @ %replacehydration);
- }
- else
- {
- messageClient(%client,'',"\c6Hydration status:\c3 " @ %client.hydration @ "\c6/\c3" @ $HungerMod::pref::MaxHydration);
- }
- }
- }
- }
- }
- //Events
- function GameConnection::setFood(%client, %input)
- {
- %client.food = %input;
- }
- function GameConnection::addFood(%client, %input)
- {
- %client.food = %client.food + %input;
- }
- function GameConnection::setHunger(%client, %input)
- {
- %ifhunger = %client.hunger + %input;
- if(%ifhunger >= $HungerMod::pref::MaxHunger)
- {
- %client.hunger = $HungerMod::pref::MaxHunger;
- }
- else
- {
- %client.hunger = %client.hunger + %input;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment