Help in improving weapon anti cheat
#1

Here is my current Anti Cheat:
pawn Код:
public AntiCheat(playerid)
{
    if(IsPlayerConnected(playerid) && GetPVarInt(playerid, "LoggedIn") == 1)
    {
        new
            string[256];
           
        if(GetPlayerMoney(playerid) != Player[playerid][pMoney])
        {
            ResetPlayerMoney(playerid);
            GivePlayerMoney(playerid, Player[playerid][pMoney]);
        }
       
        if(!IsPlayerInAnyVehicle(playerid))
        {
            switch(GetPlayerWeapon(playerid))
            {
                case 0, 1:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][0])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 2 .. 9:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][1])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 22 .. 24:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][2])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 25 .. 27:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][3])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 28, 29, 32:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][4])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 30, 31:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][5])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 33, 34:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][6])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 35 .. 38:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][7])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 16, 17, 18, 39:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][8])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 41 .. 43:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][9])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 11 .. 15:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][10])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 44 .. 46:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][11])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
                case 40:
                {
                    if(GetPlayerWeapon(playerid) != Player[playerid][pWeapons][12])
                    {
                        SetPVarInt(playerid, "wep_hack_check", GetPVarInt(playerid, "wep_hack_check") + 1);
                       
                        if(GetPVarInt(playerid, "wep_hack_check") == 4)
                        {
                            format(string, sizeof string, "Weapon Hacking (%d)", GetPlayerWeapon(playerid));
                            SendClientMessage(playerid, Colour_White, string);
                            return 1;
                        }
                    }
                }
            }
        }
    }
    return 1;
}
It gets called every time OnPlayerUpdate is called but I feel that is a bad way in doing it as a player might be lagging and therefore get banned for something they didn't do. Could someone tell me what I could do to improve the reliability of my Anti Cheat.
Reply


Messages In This Thread
Help in improving weapon anti cheat - by arko123 - 16.07.2014, 09:02
Re: Help in improving weapon anti cheat - by Hanger - 16.07.2014, 09:16
Re: Help in improving weapon anti cheat - by Blast3r - 16.07.2014, 09:22

Forum Jump:


Users browsing this thread: 1 Guest(s)