Anti-Cheat Bug Help
#1

This anti cheat seems to have a bug that i need ironing out with the help from you guys/girls.

I dont get any errors and it does work when a player has any weapon they get banned.

BUT for some reason when a player joins when someone has cheated and got banned, they are banned. I'm still a beginner at scripting so im not sure whats wrong. Please help me out.

pawn Код:
forward timer();
public timer()
{
    for(new a=0; a<MAX_PLAYERS; a++)
    {
        if(IsPlayerConnected(a))
 {
    if(IsPlayerInAnyVehicle(a))
   {

            }
            else if(GetPlayerWeapon(a) >= 1)
            {
                GetPlayerName(a,pname,MAX_PLAYER_NAME);
                SendClientMessage(a,COLOR_RED,"You have been banned for weapon Cheats!");
                Ban(a);
                format(string,sizeof(string),"Player %s has been banned for using Cheats",pname);
                SendClientMessageToAll(COLOR_RED,string);
                return 1;
            }
            else
            {
                new Float:armour;
                GetPlayerArmour(a, armour);
                if(armour > 0.0)
                {
                  SendClientMessage(a, COLOR_RED, "Armour is not allowed on this server");
                    GetPlayerName(a, pname, MAX_PLAYER_NAME);
                    Ban(a);
                    format(string,sizeof(string),"Player %s has been banned for Armour Cheats",pname);
                    SendClientMessageToAll(COLOR_RED,string);
                }
            }
        }
    }
    return 1;
}
Reply
#2

Sorry. forget this reply. Did it by accident. :@
Reply
#3

if(GetPlayerWeapon(a) >= 1)


If any player has a weapon that's on the WeaponID list higher than the brass knuckles (i.e. every weapon bust fists) the player gets banned?
Reply
#4

No thats not the problem. Ive had it before without >= 1 and it still did the same thing.

Player Cheats = Gets Banned

Player joins after someone got banned = Gets Banned

Reply
#5

pawn Код:
public timer()
{
    for(new a=0; a<MAX_PLAYERS; a++)
    {
        if(IsPlayerConnected(a))
        {
            new Float:armour;
            GetPlayerArmour(a, armour);
           
            if(IsPlayerInAnyVehicle(a))
            {

            }
            else if(GetPlayerWeapon(a) >= 1)
            {
                GetPlayerName(a,pname,MAX_PLAYER_NAME);
                SendClientMessage(a,COLOR_RED,"You have been banned for weapon Cheats!");
                Ban(a);

                format(string,sizeof(string),"Player %s has been banned for using Cheats",pname);
                SendClientMessageToAll(COLOR_RED,string);
                return 1;
            }
            else if(armour > 0.0)
            {
                SendClientMessage(a, COLOR_RED, "Armour is not allowed on this server");
                GetPlayerName(a, pname, MAX_PLAYER_NAME);
                Ban(a);
                   
                format(string,sizeof(string),"Player %s has been banned for Armour Cheats",pname);
                SendClientMessageToAll(COLOR_RED,string);
            }
        }
    }
    return 1;
}
Reply
#6

A little more optimized

pawn Код:
forward timer();
public timer()
{
    for(new a=0; a<MAX_PLAYERS; a++)
    {
        if(!IsPlayerConnected(a)) continue;
        if(!IsPlayerInAnyVehicle(a)) continue;

        if(GetPlayerWeapon(a) >= 1)
        {
            GetPlayerName(a,pname,MAX_PLAYER_NAME);
            SendClientMessage(a,COLOR_RED,"You have been banned for weapon Cheats!");
            Ban(a);

            format(string,sizeof(string),"Player %s has been banned for using Cheats",pname);
            SendClientMessageToAll(COLOR_RED,string);
            continue;
        }
       
        new Float:armour;
        GetPlayerArmour(a, armour);
       
        if(armour > 0.0)
        {
            SendClientMessage(a, COLOR_RED, "Armour is not allowed on this server");
            GetPlayerName(a, pname, MAX_PLAYER_NAME);
            Ban(a);

            format(string,sizeof(string),"Player %s has been banned for Armour Cheats",pname);
            SendClientMessageToAll(COLOR_RED,string);
        }
    }
    return 1;
}
Reply
#7

You guys don't seem to understand
pawn Код:
if(GetPlayerWeapon(a) >= 1)
{
  //ban code
}
GetPlayerWeapon gives you the weapon's ID, the only weapon that is weaponid '0' is the 'fists' weapon, or no weapon. So if you have ANY weapon, that above code will succeed and perform the ban code.
Reply
#8

Quote:
Originally Posted by dice7
A little more optimized

pawn Код:
forward timer();
public timer()
{
    for(new a=0; a<MAX_PLAYERS; a++)
    {
        if(!IsPlayerConnected(a)) continue;
        if(!IsPlayerInAnyVehicle(a)) continue;

        if(GetPlayerWeapon(a) >= 1)
        {
            GetPlayerName(a,pname,MAX_PLAYER_NAME);
            SendClientMessage(a,COLOR_RED,"You have been banned for weapon Cheats!");
            Ban(a);

            format(string,sizeof(string),"Player %s has been banned for using Cheats",pname);
            SendClientMessageToAll(COLOR_RED,string);
            continue;
        }
       
        new Float:armour;
        GetPlayerArmour(a, armour);
       
        if(armour > 0.0)
        {
            SendClientMessage(a, COLOR_RED, "Armour is not allowed on this server");
            GetPlayerName(a, pname, MAX_PLAYER_NAME);
            Ban(a);

            format(string,sizeof(string),"Player %s has been banned for Armour Cheats",pname);
            SendClientMessageToAll(COLOR_RED,string);
        }
    }
    return 1;
}
That one doesnt seem to work at all now
Reply
#9

Quote:
Originally Posted by Joe Staff
You guys don't seem to understand
pawn Код:
if(GetPlayerWeapon(a) >= 1)
{
  //ban code
}
GetPlayerWeapon gives you the weapon's ID, the only weapon that is weaponid '0' is the 'fists' weapon, or no weapon. So if you have ANY weapon, that above code will succeed and perform the ban code.
I dont get you. Are you saying thats a good thing or a bad thing?
Reply
#10

Nice anti cheats, I will try to work on my server too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)