SA-MP Forums Archive
Anti-Cheat Bug Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anti-Cheat Bug Help (/showthread.php?tid=96152)



Anti-Cheat Bug Help - indy-greg - 06.09.2009

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



Re: Anti-Cheat Bug Help - indy-greg - 06.09.2009

Sorry. forget this reply. Did it by accident. :@


Re: Anti-Cheat Bug Help - Joe Staff - 06.09.2009

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?


Re: Anti-Cheat Bug Help - indy-greg - 06.09.2009

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




Re: Anti-Cheat Bug Help - yeswecanchange09 - 06.09.2009

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



Re: Anti-Cheat Bug Help - dice7 - 06.09.2009

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



Re: Anti-Cheat Bug Help - Joe Staff - 07.09.2009

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.


Re: Anti-Cheat Bug Help - indy-greg - 07.09.2009

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


Re: Anti-Cheat Bug Help - indy-greg - 07.09.2009

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?


Re: Anti-Cheat Bug Help - Ironboy500 - 07.09.2009

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