Edit: doesn't work.
function Player::HungerLoop(%this, %hunger)
{
%client = %this.client;
if(!isObject(%this)) //Return the function if nothing exists, usually happens when you call your client's player to use this function that doesn't exist or something like that
return;
//This runs on a schedule, this helps prevent multiple schedules running on an object, this is always recommended to do.
cancel(%this.hungerLoopSch);
if(%this.getState() $= "dead") //If it is dead do not continue the code (return it)
return;
if(%hunger <= 0)
%this.addHealth(-1);
else
{
%hunger--;
bottomPrint(%client, "your hunger is" SPC %hunger, 5);
}
%this.hungerLoopSch = %this.schedule(5000, "HungerLoop", %hunger);
}
//Done.
//Because we don't have it called yet, it won't work, so we need to make a way for it to work.
package blah
{
//This happens when a player spawns
function Armor::onAdd(%armor, %playerObject)
{
Parent::onAdd(%armor, %playerObject);
if(isObject(%client = %playerObject.client) && isObject(%minigame = %client.minigame)) //Do they have a client and a minigame?
if(%playerObject.getClassName() $= "Player")
%playerObject.HungerLoop(100); //Call it, set their hunger to 100 //you might have used the wrong varible.
}
};
activatePackage("blah");