Health Float Problem
#1

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?
Reply
#2

Код:
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.
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)