Anti-Cheat Failure.
#1

Hey there,

I've been busy scripting a new AntiCheat system for my server, but, for what ever reason it bans players even when they are not hacking. I've added it a bit for when a player registers, however, when that player spawns, it bans them.

Code:

pawn Код:
UpdatePlayer(playerid)
{
    // AntiCheat
    if(!JustRegistered[playerid])
    {
        new RealMoney = GetPlayerCash(playerid), String[128], PlayerName[MAX_PLAYER_NAME];
        if(GetPlayerMoney(playerid) != RealMoney)
        {
            ResetPlayerMoney(playerid);
            GivePlayerCash(playerid, RealMoney);
            GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
            format(String, sizeof(String), "AdmWarning: %s Is possibly hacking money - Cash Reset.", PlayerName);
            SendClientMessageToAdmins(COLOR_AAC, String);
            PlayerHacking[playerid]++;
        }
        new Float:health;
        if(GetPlayerHealth(playerid, health) == 100.0)
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0)
            {
                SetPlayerHealth(playerid, 99.9);
                GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
                format(String, sizeof(String), "AdmWarning: %s Is possibly hacking health - Health Reset.", PlayerName);
                SendClientMessageToAdmins(COLOR_AAC, String);
                PlayerHacking[playerid]++;
            }
            return 1;
        }
        if(GetPlayerArmour(playerid, health) == 100.0)
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0)
            {
                SetPlayerArmour(playerid, 99.9);
                GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
                format(String, sizeof(String), "AdmWarning: %s Is possibly hacking armour - Armour Reset.", PlayerName);
                SendClientMessageToAdmins(COLOR_AAC, String);
                PlayerHacking[playerid]++;
            }
            return 1;
        }
        if(PlayerHacking[playerid] == 3 && PlayerInfo[playerid][pAdminLevel] == 0)
        {
            ResetPlayerMoney(playerid);
            SetPlayerHealth(playerid, 0.0);
            SetPlayerArmour(playerid, 0.0);
            ResetPlayerWeapons(playerid);
            BanPlayer(playerid, "General Cheats.", -1);
        }
        if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK && PlayerInfo[playerid][pAdminLevel] == 2)
        {
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE); // Reset the player.
            format(String, sizeof(String), "AdmWarning: %s Is possibly jetpack hacking - Jetpack Reset.", PlayerName);
            SendClientMessageToAdmins(COLOR_AAC, String);
            PlayerHacking[playerid] ++;
            PlayerUsingJetpack[playerid] = true;
        }
        if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN)
        {
            BanPlayer(playerid, "General Cheats.", -1);
        }

        SetPlayerScore(playerid, PlayerInfo[playerid][pKills]);
        SetPlayerScore(playerid, GetPlayerScore(playerid) - PlayerInfo[playerid][pDeaths]);
        OnPlayerSave(playerid);
        OnPlayerPingUpdate(playerid);

        PlayerSeconds[playerid]++;
        if(PlayerSeconds[playerid] == 60)
        {
            PlayerMinutes[playerid]++;
            PlayerSeconds[playerid] = 0;
        }
        if(PlayerMinutes[playerid] == 60)
        {
            PlayerHours[playerid]++;
            PlayerSeconds[playerid] = 0;
        }
        return 1;
    }
    return 1;
}
It doesn't return any errors inside the script. Just as the player spawns.
Reply
#2

Your method of retrieving health and armor is incorrect. You need to do it before the if check and then store it in the variable and use the variable in the check. Health is set to 100 on spawn so I don't personally use health hack detection, only armor. Also, just set the player's money to the real value instead of warnings admins. It will spam up your warnings and it's pretty harmless. As for your jetpack, you're only banning people with the AdminLevel 2.
Reply
#3

Alright, so basically I failed completely D I wrote the code really quickly without really checking it fully. Thanks for the help and advice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)