Help with anti-health - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with anti-health (
/showthread.php?tid=639667)
Help with anti-health -
,TomY' - 21.08.2017
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);
Re: Help with anti-health -
Toroi - 21.08.2017
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.
Re: Help with anti-health -
HydraHumza - 21.08.2017
It wouldn't patch the bullet proof anti cheat. The best you can do regarding this matter, you can use serversided health and armour.