SA-MP Forums Archive
Well, I think Pawn has gone crazy - 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: Well, I think Pawn has gone crazy (/showthread.php?tid=620521)



Well, I think Pawn has gone crazy - NeXoR - 30.10.2016

Heya, Here is my HealthHack code:
PHP код:
forward HealthHack();
public 
HealthHack()
{
    new 
Float:hpFloat:ap;
    foreach(new 
playerid Player)
    {
        if(
PlayerInfo[playerid][pSpawned] && !SpawnProtected[playerid])
        {
            if(!
GivingHealth[playerid] && !GivingArmour[playerid])
            {
                
GetPlayerHealth(playeridhp);
                
GetPlayerArmour(playeridap);
                
printf("Debug Health: %.0f Armour: %.0f || HP: %.0f AP: %.0f"Health[playerid], Armour[playerid], hpap);
                if(
hp != Health[playerid] || ap != Armour[playerid]) AddBan(playeridRPN(playerid), "Anti Cheat""Health Hacking"RPIP(playerid));
            }
            else
            {
                
GivingHealth[playerid] = 0;
                
GivingArmour[playerid] = 0;
            }
        }
    }
    return 
1;

That's the latest printf on the console:
Код:
Debug Health: 100 Armour: 17 || HP: 100 AP: 17
I got banned after this, what the hell ...


Re: Well, I think Pawn has gone crazy - Kaliber - 30.10.2016

Try floatcmp

and you should print with %f to look exactly


Re: Well, I think Pawn has gone crazy - Mauzen - 30.10.2016

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));


Re: Well, I think Pawn has gone crazy - NeXoR - 31.10.2016

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
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));
Had a quick edit to round method tozero since regular rounding was buggy
Now working smoothly, thank you