Help with SetPlayerHealth - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with SetPlayerHealth (
/showthread.php?tid=580478)
Help with SetPlayerHealth -
Sc0pion - 05.07.2015
Fixed!
Re: Help with SetPlayerHealth -
Threshold - 05.07.2015
pawn Код:
if(dialogid == DIALOG_FOOD)
{
if(!response) return 1;
switch(listitem)
{
case 0://Ice Cream
{
if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, red, "[ ERROR: You must have $1 to purchase an Ice Cream. ]");
new Float:hp;
GetPlayerHealth(playerid, hp);
SetPlayerHealth(playerid, ((hp + 10.0) >= 100.0) ? (100.0) : (hp + 10.0));
GivePlayerMoney(playerid, -1);
SendClientMessage(playerid, COLOR_YELLOW, "[ NOTIFICATION: You have purchased an Ice Cream for $1. ]");
return 1;
}
}
}
You weren't using GetPlayerHealth before the 'if(hp + 10.0 > 100.0)' line, so hp was equal to 0.