GetPlayerHealth problem?
#1

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

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

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

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

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


Forum Jump:


Users browsing this thread: 4 Guest(s)