[SOLVED] Help Fix My Anticheat Quick!
#1

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;
}
Reply
#2

Hmm, set weap to 0 before You use GetPlayerWeaponData.

OR: Use GetPlayerWeapon. This is better...
Reply
#3

And use in OnPlayerUpdate
Reply
#4

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.
Reply
#5

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.
Reply
#6

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)