getplayerhealth problem?
#5

Also, the health is a float.
Never use
pawn Код:
GetPlayerHealth(playerid,health);
if(health == 100) return SendClientMessage(playerid,lightyellow,"I think you are bit too full for eating");
Floats tend to be inaccurate for checking directly.
Your health could be 100.000001 or so (because of the way computers work with floats and they have a limited amount of bits to represent a floating value), the == will never succeed.
The 100.000001 could be stored this way in the computer's memory, but when printing it with fewer digits after the comma, it's rounded down to 100.00 for example. But the real value is still 100.000001.

Use this instead:
pawn Код:
GetPlayerHealth(playerid,health);
if(health > 99.9) return SendClientMessage(playerid,lightyellow,"I think you are bit too full for eating");
Reply


Messages In This Thread
getplayerhealth problem? - by Tanush123 - 03.01.2012, 21:18
Re: getplayerhealth problem? - by Vince - 03.01.2012, 21:26
Re: getplayerhealth problem? - by geerdinho8 - 03.01.2012, 21:30
Re: getplayerhealth problem? - by FireCat - 03.01.2012, 21:37
Re: getplayerhealth problem? - by PowerPC603 - 03.01.2012, 21:46
Re: getplayerhealth problem? - by cessil - 03.01.2012, 22:14
Re: getplayerhealth problem? - by PowerPC603 - 03.01.2012, 22:39
Re: getplayerhealth problem? - by Basssiiie - 03.01.2012, 23:13
Re: getplayerhealth problem? - by Tanush123 - 04.01.2012, 02:31

Forum Jump:


Users browsing this thread: 1 Guest(s)