SA-MP Forums Archive
Deduct HP instead of setting it to a negative point - 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: Deduct HP instead of setting it to a negative point (/showthread.php?tid=397194)



Deduct HP instead of setting it to a negative point - 69 - 03.12.2012

I wish to deduct HP. For example, if a player does something, I want 60 hp points to be deducted from him.

I know it's not SetPlayerHealth... or is it?


Re: Deduct HP instead of setting it to a negative point - DaRk_RaiN - 03.12.2012

Well you have to use this
PHP код:
 new Float:HP;//  You can change the fload name from HP to what ever. 
then
PHP код:
    GetPlayerHealth(playeridHP); //We're saving it to our new Float:HP variable.
    
SetPlayerHealth(playerid, (HP60)); 
//you can change the ammount to 50 or...


Re: Deduct HP instead of setting it to a negative point - Sinner - 03.12.2012

Make sure the value doesn't go negative aswel:

pawn Код:
new Float:hp;
GetPlayerHealth(playerid, hp);
SetPlayerHealth(playerid, (hp - 60 >= 0) ? (hp - 60) : 0);