27
« on: July 29, 2017, 07:18:41 PM »
I wrote a simple hunger mod for some guy a while ago, I guess you can take a look at the code. I'm not really going to explain whats going on though, sorry:
$hydra::hungerTickTime = 30000;
function gameConnection::hunger_start(%this)
{
%this.hunger = 100;
%this.hungerTick();
}
function gameConnection::hunger_end(%this)
{
cancel(%this.hungerTick);
}
function gameConnection::hungerTick(%this)
{
cancel(%this.hungerTick);
%player = %this.player;
if(isObject(%player))
{
%this.hunger--;
if(%this.hunger <= 0)
{
//do dmg
%this.hunger = 0;
%this.player.addHealth(-5);
bottomPrint(%this,"\c0Hunger: \c2" @ %this.hunger @ "\c0% - Taking Damage.",5);
}
else
{
bottomPrint(%this,"\c6Hunger: \c2" @ %this.hunger @ "\c6%",5);
}
}
%this.hungerTick = %this.schedule($hydra::hungerTickTime,hungerTick);
}