Health Float Problem - 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: Health Float Problem (
/showthread.php?tid=328562)
Health Float Problem -
Matz - 25.03.2012
Hi. In short;
Код:
SetPlayerHealth(playerid,100);
new Float:health; GetPlayerHealth(playerid,health);
new Float:maxhealth = PlayerInfo[playerid][pHP];
if(PlayerInfo[playerid][pHP] > 0) return SetPlayerHealth(playerid,health+maxhealth);
What happens;

(10 hp ;o)
What I meant to;

(100 default and +10 HP from .ini [pHP] so 110 hp. As you know we can't see it in bar)
Can anyone explain me what is the problem in code?
Re: Health Float Problem -
Alternative112 - 25.03.2012
Код:
SetPlayerHealth(playerid,100.0); //SetPlayerHealth wants floats.
new Float:health;
GetPlayerHealth(playerid, health);
new Float:maxhealth;
maxhealth = PlayerInfo[playerid][pHP];
if(maxhealth > 0) return SetPlayerHealth(playerid, health + maxhealth);
Not sure why you're using PlayerInfo[playerid][pHP] in your if statement since you are setting it as the value of
maxhealth...Try this. If that doesn't work, try making a separate float for health + maxhealth, and just putting that as the second argument for your SetPlayerHealth.
Re: Health Float Problem -
Matz - 25.03.2012
Quote:
Originally Posted by Alternative112
Код:
SetPlayerHealth(playerid,100.0); //SetPlayerHealth wants floats.
new Float:health;
GetPlayerHealth(playerid, health);
new Float:maxhealth;
maxhealth = PlayerInfo[playerid][pHP];
if(maxhealth > 0) return SetPlayerHealth(playerid, health + maxhealth);
Not sure why you're using PlayerInfo[playerid][pHP] in your if statement since you are setting it as the value of maxhealth...Try this. If that doesn't work, try making a separate float for health + maxhealth, and just putting that as the second argument for your SetPlayerHealth.
|
Thanks but still same problem, I have removed it cause begin think useless feature on gamemode.