PHP код:
public SetPlayerHungerEx(playerid, Float: x, time)
{
new Float: health;
if(x > 0)
{
TextDrawShowForPlayer(playerid, FoodProgressPlus);
if(ProgressBarValue[playerid][BAR_FOOD] < 100)
{
ProgressBarValue[playerid][BAR_FOOD]++;
switch(ProgressBarValue[playerid][BAR_FOOD])
{
case 53: { Hunger(playerid, 1); TextDrawHideForPlayer(playerid, FoodProgressWarning); SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are no longer suffering from hunger."); }//52.5 is 50 precent
case 44: { Hunger(playerid, 1); SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your hunger level has decreased. You are suffering from hunger level 1."); }//62.0 is 60 percent
case 34: { Hunger(playerid, 1); SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your hunger level has decreased. You are suffering from hunger level 2."); }//71.5 is 70 percent
case 25: { Hunger(playerid, 1); SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your hunger level has decreased. You are suffering from hunger level 3."); }//81.0 is 80 percent
case 15: { Hunger(playerid, 1); SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your hunger level has decreased. You are suffering from hunger level 4."); }//90.5 is 90 percent
case 6: { Hunger(playerid, 1); SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your hunger level has decreased. You are suffering from hunger level 5."); }//90.5 is 90 percent
}
}
else
{
GetPlayerHealth(playerid, health);
health = health - 1.0;
SetPlayerHealth(playerid, health);
if(health <= 0.0)
{
PlayerInfo[playerid][pSpawn] = 99;
}
if(PlayerInfo[playerid][pRace] == 2)
{
if(x == 1)
{
SetTimerEx("Vomit", 15000+random(15000), false, "i", playerid);
}
}
else
{
if(x == 1)
{
SetTimerEx("Vomit", 15000+random(15000), false, "i", playerid);
}
}
}
x--;
}
else if(x < 0)
{
TextDrawShowForPlayer(playerid, FoodProgressMinus);
if(ProgressBarValue[playerid][BAR_FOOD] > 5)
{
ProgressBarValue[playerid][BAR_FOOD] -= 1;
switch(ProgressBarValue[playerid][BAR_FOOD])
{
case 52: { Hunger(playerid, -1); TextDrawShowForPlayer(playerid, FoodProgressWarning); SendClientMessage(playerid, COLOR_WHITE, "You are suffering from hunger level 1."); }//62.0 is 60 percent
case 43: { Hunger(playerid, -1); SendClientMessage(playerid, COLOR_RED, "SERVER: Your hunger level has increased. You are suffering from hunger level 2."); }//71.5 is 70 percent
case 33: { Hunger(playerid, -1); SendClientMessage(playerid, COLOR_RED, "SERVER: Your hunger level has increased. You are suffering from hunger level 3."); }//81.0 is 80 percent
case 24: { Hunger(playerid, -1); SendClientMessage(playerid, COLOR_RED, "SERVER: Your hunger level has increased. You are suffering from hunger level 4."); }//90.5 is 90 percent
case 14: { Hunger(playerid, -1); SendClientMessage(playerid, COLOR_RED, "SERVER: Your hunger level has increased. You are suffering from hunger level 5."); }//100.0 is 100 percent
case 5: { Hunger(playerid, -1); SendClientMessage(playerid, COLOR_RED, "SERVER: Your hunger level has increased. You are suffering from hunger level 6."); }//100.0 is 100 percent
}
}
x++;
}
SetProgressBarValue(BAR_FOOD, playerid, ProgressBarValue[playerid][BAR_FOOD]);
ShowProgressBarForPlayer(BAR_FOOD, playerid);
if(x != 0)
{
SetTimerEx("SetPlayerHungerEx", time, false, "iii", playerid, Float: x, time);
return 1;
}
TextDrawHideForPlayer(playerid, FoodProgressPlus);
TextDrawHideForPlayer(playerid, FoodProgressMinus);
return 1;
}