Limiting Player's health.
#1

Hi there. Is there a way to limit the health of all players to 99.0 because im making an anti cheat and when player has 100 then it could be a possible health hack. Is there any way to limit the health to 99.0?
Reply
#2

Yeah, hook SetPlayerHealth so if it's over 99.0 then set it to 99.0 (take in consideration vending machines and so on).
Reply
#3

Is there any way that keeps updating the player with the health? public OnPlayerUpdate?
Reply
#4

OnPlayerUpdate can cause massive lag, it needs to be handled carefully, but who gives a damn about it when we have taking and giving damage callbacks..
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)   // ensure that issuer is not invalid
    {
        new Float:Health;
        GetPlayerHealth(playerid, Health); // saved the current health
		if(amount > 99.0)   // checked the amount if its above 99.0
		    SetPlayerHealth(playerid, 99.0); // then set it back to 99.0
		else
		    SetPlayerHealth(playerid, Health + amount); // otherwise give the player the same amount which is taken from him by issuer
    }
    return 1;
}
Reply
#5

Managed to make it but it will be sent only 1 time using sendtoadmin. Right? But anticheat keeps sending the warning message repeatly. How can i make it to keep sending the message repeatly?What i did is this.
Код:
public OnPlayerUpdate(playerid)
{
    new Float:Health2;
	if(GetPlayerHealth(playerid, Health2) >= 100)
	{
		new string[120];
	    format(string, sizeof(string), "%s is health hacking.(Server player health: 99, Player health: %d)", PN(playerid), GetPlayerHealth(playerid, Health2));
 		SendToAdmins(COLOR_RED, string);
 	}
    return 1;
}
Reply
#6

And this procedure applies same for the weapons?
Reply
#7

Your code will spam admins chat on every move he will do.
Try this one:

Код:
stock _SetPlayerHealth(playerid, health)
{
        if(health >= 100)
        {
	       SetPlayerHealth(playerid, 99));
        }
}
#define SetPlayerHealth(%0,%1) _SetPlayerHealth(%0, %1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)