Help with anti-health
#1

Hi. Trying to do health, armour anti-cheat, but sometimes it kick player when he is spawning, sometimes is good.. Why?

Code:

Код:
stock AntiCheat(playerid)
{
	if(!PlayerInfo[playerid][spawned]) return 0;
	if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
    {
	new Float:amount;
	GetPlayerHealth(playerid, amount);
    if(amount > 99) return Kick(playerid,"Health cheat");
    GetPlayerArmour(playerid, amount);
    if(amount > 99) return Kick(playerid,"Armour cheat");
    }
	return 1;
}
Then I put line AntiCheat(playerid); in onplayerupdate.
Also in onplayerspawn:
Код:
 SetPlayerHealth(playerid, 98);
    SetPlayerArmour(playerid, 0);
    PlayerInfo[playerid][spawned] = true;
And onplayerconnect
Код:
    SetPlayerHealth(playerid, 98);
    SetPlayerArmour(playerid, 0);
Reply
#2

Because players spawn with 100 health. The cases where the player gets kicked happens when OnPlayerUpdate gets called in the middle of the player spawning and you setting their health to 98. Your 'anticheat' notices the player has more than 99 of health (100) and kicks them.

For the solution, use player timers instead of OnPlayerUpdate, kill the timer when the player dies and create it again after the player spawns and you set him 98 of health.

I'll use my free speech to point out that this way of anticheat is pretty useless now, it most likely won't work with newer kind of cheats where the cheat doesn't set the health to 100 but to the one the server sets.
Reply
#3

It wouldn't patch the bullet proof anti cheat. The best you can do regarding this matter, you can use serversided health and armour.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)