SA-MP Forums Archive
Some function trouble - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Some function trouble (/showthread.php?tid=261153)



Some function trouble - DjAdy - 12.06.2011

I'm trying to make a special drug command but i doesn't work as i wanted it to. I've made the basics i needed but i need the function to get the players health and then add to it not setting it i've tryed this

SetPlayerHealth(playerid, GetPlayerHealth(playerid) + 25);
it gave me an error
i've tryed like on wiki still error

I don't know what to do if someone can help me it'll be apreciated, thanks in advance.


Re: Some function trouble - Sinner - 12.06.2011

pawn Код:
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health+25);



Re: Some function trouble - Ash. - 12.06.2011

Or you can use a custom function, add this to somewhere (maybe the bottom) of your code:

pawn Код:
stock GivePlayerHealth(playerid, Float:amount)
{
     static Float:health;
     GetPlayerHealth(playerid, health);
     SetPlayerHealth(playerid, health+amount);
}
Then instead of having a block of code to do one thing, just call the function above.

(GivePlayerHealth(playerid, amount))


Re: Some function trouble - DjAdy - 12.06.2011

thanks alot ,i owe ya one