03.11.2016, 15:16
Hey guys I am having a bug, when I set someone's HP to 1000, it sets his IG (getplayerhealth) HP to 293, what should I do?
Originally Posted by https://sampwiki.blast.hk/wiki/GetPlayerHealth
Even though the health can be set to near infinite values on the server side, the individual clients will only report values up to 255. Anything higher will wrap around; 256 becomes 0, 257 becomes 1, etc.
|
I know you meant that he should learn how to respond with the solutions but something tells me he will never come back to this thread ever again anyways.
|
enum playerInfo{ Float:pHealth }; new pInfo[MAX_PLAYERS][playerInfo]; OnPlayerTakeDamage(...) { GetPlayerHealth(playerid, pInfo[playerid][pHealth]); return 1; } OnPlayerUpdate(...) { SetPlayerHealth(playerid, pInfo[playerid][pHealth]); return 1; }
If you want to create some kind of admin invincibility, then I suggest you set the health of a player everytime they take the damage (OnPlayerTakeDamage(...) callback), alternatively OnPlayerUpdate to keep resetting them.
Specifically for anti-hack, I suggest you very much use OnPlayerUpdate and set their health (SetPlayerHealth) by having it saved down into a player enum everytime it changes. Example of what I mean: Код:
enum playerInfo{ Float:pHealth }; new pInfo[MAX_PLAYERS][playerInfo]; OnPlayerTakeDamage(...) { GetPlayerHealth(playerid, pInfo[playerid][pHealth]); return 1; } OnPlayerUpdate(...) { SetPlayerHealth(playerid, pInfo[playerid][pHealth]); return 1; } |