SetPlayerHealth bug
#1

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

Solved
Reply
#3

What about telling everyone what was the problem and how did you fix it?
Reply
#4

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

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
What about telling everyone what was the problem and how did you fix it?
I agree with GoldenLion, remember, after a few years, people might be having the same problem, searching for help, and they might find this topic, in hope of finding the solution... Just a quick tip for the future.
Reply
#6

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
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.
Haha, actually I will ever get back to this thread, I am checking threads opened by me and if the response is new I enter, no matter if I got an answer or not, because I might have a newer answer.

O.T - After reading the actual post about GetPlayerHealth() I realized that if the player has more than 255 HP it's saved (for the saver) as 255, any amount above will be the amount - 256, AKA: 256 - 0, 257 - 1 and so on.
So I have 2 options, maximize the amount of HP to 255 or, ughm, find another method of Anti Health Hack
Reply
#7

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;
}
That way the health is considered somewhat server-sided and not client-sided. If they would "cheat" to set their health, it would never save it down to pInfo[playerid][pHealth] and therefore their HP would still set to what was previously used. This is just an example however and there are more ways to do it!
Reply
#8

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
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;
}
That way the health is considered somewhat server-sided and not client-sided. If they would "cheat" to set their health, it would never save it down to pInfo[playerid][pHealth] and therefore their HP would still set to what was previously used. This is just an example however and there are more ways to do it!
I have a better solution
If you /sethp someone's HP to higher than 255, you get blocked and are being told to use /god.

/god is a command I just made further to this question, simply if(GodMode[hitid]) return 0; under OnPlayerWeaponShot

Thanks anyways for trying mate
My anti hack is quiet more powerful, if your HP (getplayerhealth) or armor != your HP / AP variable, Banned.
That's why it's so hard to make it, to prevent ANY unnecessary bans
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)