GetPlayerHealth 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: GetPlayerHealth problem? (
/showthread.php?tid=448457)
GetPlayerHealth problem? -
exclide1 - 04.07.2013
Hello. I set my health with "SetPlayerHealth(playerid, 9999.0)" and then I check if my health is less then 100 with
Код:
new Float:pHealth;
GetPlayerHealth(playerid, Float:pHealth);
if (pHealth < 100.0) return SendClientMessage(playerid, COLOR_RED, "You must be at full health to use this.");
And fore some reason it returns that message, even though my health is "9999.0"! And then, when I set it to "99999.0" it's OK! What's the deal?
Re: GetPlayerHealth problem? -
Antonio144 - 04.07.2013
Health ranges from 0 to 100.0, so if you set your health to 9999.0 its the same as 100.0.
Try setting your health to 99.0.
Re: GetPlayerHealth problem? -
exclide1 - 04.07.2013
Quote:
Originally Posted by Antonio144
Health ranges from 0 to 100.0, so if you set your health to 9999.0 its the same as 100.0.
Try setting your health to 99.0.
|
I've made this
Код:
CMD:gethealth(playerid, params[])
{
new string[256], Float:shit;
GetPlayerHealth(playerid, Float:shit);
format(string, sizeof(string), "health is %f", shit);
SendClientMessage(playerid, -1, string);
return 1;
}
And it shows me "15.0" when the health is set to "9999.0" and "159.0" when it's set to "99999.0". I'm having problems with my anti-health hack due to this and spawn protection.
Respuesta: Re: GetPlayerHealth problem? -
Gryphus One - 04.07.2013
Quote:
Originally Posted by Antonio144
Health ranges from 0 to 100.0, so if you set your health to 9999.0 its the same as 100.0.
Try setting your health to 99.0.
|
I don't think so: how do you think spawn protection works, other than setting one's health to a very high value? However I have noticed that if I set my health to a very high value and then I use GetPlayerHealth, it will say I have 159 hp.
Re: GetPlayerHealth problem? -
exclide1 - 04.07.2013
Quote:
Originally Posted by ******
Health can (IIRC) only be between 0 and 255, therefore any number you set is modified modulo 256.
|
Thanks, I guess I'll have to change my spawn protection method, because if I set the health to "99999.0" at spawn it failes to verify it with anticheat variable and triggers the ban.