08.08.2012, 04:55
This loop should be placed under a timer of your choice.
I am assuming you want something like that.
The above code has not be compiled or tested.
pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++)
{
if(IsPlayerConnected(playerid))
{
new Float:health, string[128];
GetPlayerHealth(playerid, health);
if(GetProgressBarValue(hungry[playerid]) > 0)
{
SetProgressBarValue(hungry[playerid], GetProgressBarValue(hungry[playerid]) - 1)
if(GetProgressBarValue(hungry[playerid] <= 50) // Player Less Then 50% Hunger Display Message?
{
format(string, 128, "* %s starts feeling hungry.", RPN(playerid));
SendClientMessage(playerid, COLOR_HUNGRY, "You are hungry, go and eat something.");
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE);
}
}
else // Player Starving Deduct Health?
{
SetPlayerHealth(playerid, health-5);
format(string, 128, "* %s is starving.", RPN(playerid));
SendClientMessage(playerid, COLOR_HUNGRY, "You are starving. You need to eat something.");
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE);
}
}
}
The above code has not be compiled or tested.