Untested code, but a concept like this would remove the need for any looping:
package Thirst
{
function GameConnection::spawnPlayer(%this)
{
Parent::spawnPlayer(%this);
%player = %this.player;
%player.thirstLevel = 600;
%player.thirstTime = getSimTime();
%player.thirstDeath = %this.schedule(600000,thirstDeath);
}
};
activatePackage(Thirst);
function Player::thirstDeath(%this)
{
messageClient(%this.client,'',"You have died of thirst!");
%this.kill();
}
function Player::restoreThirst(%this,%amount)
{
%time = getSimTime();
%thirst = %this.thirstLevel - ((%time - %player.thirstTime) / 1000) + %amount;
%player.thirstLevel = %thirst;
%player.thirstTime = %time;
cancel(%player.thirstDeath);
%player.thirstDeath = %this.schedule(%thirst * 1000,thirstDeath);
}
1) You spawn, and get 600 thirst. Lasts you ten minutes.
2) If nothing happens to your thirst, you die in ten minutes.
3) restoreThirst should boost your life span by %amount seconds.
Example:
function serverCmdDrink(%cl)
{
%cl.player.restoreThirst(60);
}
Typing /drink would give you an extra minute of life.
This is untested, so I might've typo'd with the math.
EDIT: Found and fixed two typos.