Quote:
Originally Posted by [xB]Lordz
This may help.
Sorry if its wrong.
pawn Код:
public OnPlayerUpdate(playerid) { if(GetPlayerHealth(playerid)==1) { SetPlayerHealth(playerid,2.00); return 1; }
|
Well,YES,it is wrong,because GetPlayerHealth only STORES the health into a float variable DEFINED by YOU.So the correct code,would be:
pawn Код:
public OnPlayerUpdate(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if(health==1)
{
SetPlayerHealth(playerid,2);
}
return 1;
}
YET,you are not completely wrong,why?He asked if player's health is smaller than 1,then his health should go back to 1,BUT,OnPlayerUpdate is like a "timer" of 1 second,and I am afraid that if his health goes below 1,BEFORE THE OnPlayerUpdate code executes and prepares to set his health to 1(EVEN if it acts in 1 second),he may be killed,and his health may be 1,but death also,the result is an annoying BUG.Bla bla,so well tought Lordz,you're not completly wrong,BUT,when you do wanna help AS a newbie,first check the function on SAMP-Wiki.