SA-MP Forums Archive
[SOLVED] Help Fix My Anticheat Quick! - 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: [SOLVED] Help Fix My Anticheat Quick! (/showthread.php?tid=109688)



[SOLVED] Help Fix My Anticheat Quick! - BP13 - 21.11.2009

For some reason this is not working. When I added it to my server it pretty much banned people for no reason and just spammed "[14:51:18] BANNED: has been auto banned by console." every time the timer called this. I tested this with me and 1 other person and it worked. I don't know why its not now.

pawn Код:
forward AntiCheat(playerid);
public AntiCheat(playerid)
{
    new weap, ammo;
    for(new i = 0; i < MAX_PLAYERS; i++) //loops through players
    {
        if(IsPlayerConnected(i) && ADMIN[i] == 0) //if they are not a admin and if they are connected
        {
            if(MISSLE36[playerid] == false && FLAME37[playerid] == false && MINI38[playerid] == false) // false for these means if they are disallowed to it.
            {
                GetPlayerWeaponData(i, 7, weap, ammo); //Check invotory
                if(ammo > 1 && weap == 35) //Check Inventory for weapon ID 35
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string); //Write to log.
                Ban(playerid); //Bans the player if all 3 weapon difines were false (guns in stunt zone)
                }
                else if(ammo > 1 && weap == 36)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
                else if(ammo > 1 && weap == 37)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
                else if(ammo > 1 && weap == 38)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
                else if(ammo > 1 && weap == 44)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
                else if(ammo > 1 && weap == 45)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
                else if(ammo > 1 && weap == 35)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(playerid);
                }
            }
        }
    }
    return 1;
}



Re: Help Fix My Anticheat Quick! - Double-O-Seven - 21.11.2009

Hmm, set weap to 0 before You use GetPlayerWeaponData.

OR: Use GetPlayerWeapon. This is better...


Re: Help Fix My Anticheat Quick! - Jefff - 21.11.2009

And use in OnPlayerUpdate


Re: Help Fix My Anticheat Quick! - member - 21.11.2009

Well, first of all, it is not clear whether this is a loop through all players or the timer is being called passsing the playerid parameter. But assuming you want a general timer looping through all players then this is how it should be:

pawn Код:
SetTimer("AntiCheat",20000,1);

forward AntiCheat();
public AntiCheat()
{
    new weap, ammo;
    for(new i = 0; i < MAX_PLAYERS; i++) //loops through players
    {
        if(IsPlayerConnected(i) && ADMIN[i] == 0) //if they are not a admin and if they are connected
        {
            if(MISSLE36[i] == false && FLAME37[i] == false && MINI38[i] == false) // false for these means if they are disallowed to it.
            {
                GetPlayerWeaponData(i, 7, weap, ammo); //Check invotory
                if(ammo > 1 && weap == 35) //Check Inventory for weapon ID 35
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string); //Write to log.
                Ban(i); //Bans the player if all 3 weapon difines were false (guns in stunt zone)
                }
                else if(ammo > 1 && weap == 36)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 37)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 38)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 44)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 45)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 35)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
            }
        }
    }
    return 1;
}
The 'playerid' parameter is not used.


Re: Help Fix My Anticheat Quick! - Abernethy - 21.11.2009

Quote:
Originally Posted by [B2K
Hustler ]
Well, first of all, it is not clear whether this is a loop through all players or the timer is being called passsing the playerid parameter. But assuming you want a general timer looping through all players then this is how it should be:

pawn Код:
SetTimer("AntiCheat",20000,1);

forward AntiCheat();
public AntiCheat()
{
    new weap, ammo;
    for(new i = 0; i < MAX_PLAYERS; i++) //loops through players
    {
        if(IsPlayerConnected(i) && ADMIN[i] == 0) //if they are not a admin and if they are connected
        {
            if(MISSLE36[i] == false && FLAME37[i] == false && MINI38[i] == false) // false for these means if they are disallowed to it.
            {
                GetPlayerWeaponData(i, 7, weap, ammo); //Check invotory
                if(ammo > 1 && weap == 35) //Check Inventory for weapon ID 35
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string); //Write to log.
                Ban(i); //Bans the player if all 3 weapon difines were false (guns in stunt zone)
                }
                else if(ammo > 1 && weap == 36)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 37)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 38)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 44)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                    SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 45)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
                else if(ammo > 1 && weap == 35)
                {
                    new string [128];
                    new pName[MAX_PLAYER_NAME];
                    GetPlayerName(i, pName, sizeof(pName));
                    format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
          SendClientMessageToAll(COLOR_RED, string);
                    printf(string);
                Ban(i);
                }
            }
        }
    }
    return 1;
}
The 'playerid' parameter is not used.
He's got it. You're looping through all players, so playerid doesn't count. Use i.


Re: Help Fix My Anticheat Quick! - BP13 - 22.11.2009

Thank you guys. Ill try it and I will post back in a bit if it worked or not.


Re: Help Fix My Anticheat Quick! - BP13 - 22.11.2009

Seems to be working great so far with your update you have made. I will post any more problems if I get any. Thanks for helping Underground Stunt World with my first made anticheat. Thanks alot hustler I couldn't have done it without you.