forward HealthHack();
public HealthHack()
{
new Float:hp, Float:ap;
foreach(new playerid : Player)
{
if(PlayerInfo[playerid][pSpawned] && !SpawnProtected[playerid])
{
if(!GivingHealth[playerid] && !GivingArmour[playerid])
{
GetPlayerHealth(playerid, hp);
GetPlayerArmour(playerid, ap);
printf("Debug Health: %.0f Armour: %.0f || HP: %.0f AP: %.0f", Health[playerid], Armour[playerid], hp, ap);
if(hp != Health[playerid] || ap != Armour[playerid]) AddBan(playerid, RPN(playerid), "Anti Cheat", "Health Hacking", RPIP(playerid));
}
else
{
GivingHealth[playerid] = 0;
GivingArmour[playerid] = 0;
}
}
}
return 1;
}
Debug Health: 100 Armour: 17 || HP: 100 AP: 17
Comparing floats like this is risky, theres a rounding error in certain circumstances, so you got 100.000001 instead of 100.0. Better compare rounded values.
if(floatround(hp) != floatround(Health[playerid]) || floatround(ap) != floatround(Armour[playerid])) AddBan(playerid, RPN(playerid), "Anti Cheat", "Health Hacking", RPIP(playerid)); |