31.10.2016, 12:27
Hey guys, I am having issues with my anti health hack code
It works just fine, but sometimes it doesn't get fixed through the array
Here is the code:
Here is the function (called every 3 seconds)
Anyone ?
It works just fine, but sometimes it doesn't get fixed through the array
Here is the code:
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
switch(weaponid)
{
case 52, 53, 54:
{
if(Health[playerid] > amount) Health[playerid] -= amount;
else Health[playerid] = 0.0;
}
default:
{
if(!SpawnProtected[playerid])
{
if(Armour[playerid] > amount) Armour[playerid] -= amount;
else if(Armour[playerid])
{
amount -= Armour[playerid];
Armour[playerid] = 0.0;
if(amount)
{
if(Health[playerid] > amount) Health[playerid] -= amount;
else Health[playerid] = 0.0;
}
}
else if(Health[playerid] > amount) Health[playerid] -= amount;
else Health[playerid] = 0.0;
}
}
}
return 1;
}
PHP код:
forward HealthHack();
public HealthHack()
{
new Float:hp, Float:ap;
foreach(new playerid : Player)
{
if(PlayerInfo[playerid][pSpawned] && !SpawnProtected[playerid] && !flying[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(floatround(hp, floatround_tozero) != floatround(Health[playerid], floatround_tozero) || floatround(ap, floatround_tozero) != floatround(Armour[playerid], floatround_tozero))
AddBan(playerid, RPN(playerid), "Anti Cheat", "Health Hacking", RPIP(playerid));
}
else
{
GivingHealth[playerid] = 0;
GivingArmour[playerid] = 0;
}
}
}
return 1;
}