How to do this without spamming (onplayerupdate / sendclientmessage)
#1

Alright so this is my weapon cheat detection system

pawn Код:
enum ServerWeapons
{
    Melee,
    Thrown,
    Pistols,
    Shotguns,
    SubMachine,
    Assault,
    Rifles,
    Heavy,
    Handheld,

}
new ServerWeapons[MAX_PLAYERS][ServerWeapons];
pawn Код:
public OnPlayerUpdate(playerid)
{
CheckServerWeapons(playerid);
return 1;
}

How to make it Not to spam these admin messages?
pawn Код:
CheckServerWeapons(playerid)
{
    new weaponid = GetPlayerWeapon(playerid);

    if(weaponid >= 1 && weaponid <= 15)
    {
        if(weaponid == ServerWeapons[playerid][Melee])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a melee weapon.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1); // ABroadCast Is same as send client message but only sends to admins
            }
    }

        if( weaponid >= 16 && weaponid <= 18 || weaponid == 39 ) // Checking Thrown
    {
        if(weaponid == ServerWeapons[playerid][Thrown])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Thrown weapon.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }
    if( weaponid >= 22 && weaponid <= 24 ) // Checking Pistols
    {
        if(weaponid == ServerWeapons[playerid][Pistols])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Pistol.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }

    if( weaponid >= 25 && weaponid <= 27 ) // Checking Shotguns
    {
        if(weaponid == ServerWeapons[playerid][Shotguns])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Shotgun.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }
    if( weaponid == 28 || weaponid == 29 || weaponid == 32 ) // Checking Sub Machine Guns
    {
        if(weaponid == ServerWeapons[playerid][SubMachine])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Sub machine gun weapon.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }

    if( weaponid == 30 || weaponid == 31 ) // Checking Assault
    {
        if(weaponid == ServerWeapons[playerid][Assault])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Assault weapon.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }

    if( weaponid == 33 || weaponid == 34 ) // Checking Rifles
    {
        if(weaponid == ServerWeapons[playerid][Rifles])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a Rifle.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }
    if( weaponid >= 35 && weaponid <= 38 ) // Checking Heavy
    {
        if(weaponid == ServerWeapons[playerid][Heavy])
        {
        return 1;
        }
            else
            {
            new sendername[ MAX_PLAYER_NAME ];
            new string[128];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, 128, "AdmWarn: %s has possibly hacked a heavy weapon.", sendername);
            ABroadCast(COLOR_YELLOW, string, 1);
            }
    }
    else { return 1; }
   
return 1;
}
pawn Код:
ServerWeapon(playerid, weaponid, ammo)
{
if(weaponid >= 1 && weaponid <= 15)
    {
    ServerWeapons[playerid][Melee] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }

        if( weaponid >= 16 && weaponid <= 18 || weaponid == 39 ) // Checking Thrown
    {
    ServerWeapons[playerid][Thrown] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }
    if( weaponid >= 22 && weaponid <= 24 ) // Checking Pistols
    {
    ServerWeapons[playerid][Pistols] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }

    if( weaponid >= 25 && weaponid <= 27 ) // Checking Shotguns
    {
    ServerWeapons[playerid][Shotguns] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }
    if( weaponid == 28 || weaponid == 29 || weaponid == 32 ) // Checking Sub Machine Guns
    {
    ServerWeapons[playerid][SubMachine] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }

    if( weaponid == 30 || weaponid == 31 ) // Checking Assault
    {
    ServerWeapons[playerid][Assault] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }

    if( weaponid == 33 || weaponid == 34 ) // Checking Rifles
    {
    ServerWeapons[playerid][Rifles] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }
    if( weaponid >= 35 && weaponid <= 38 ) // Checking Heavy
    {
    ServerWeapons[playerid][Heavy] = weaponid;
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
    }
return 1;
}
Reply
#2

make a public and callback it
Reply
#3

Can you show me an example
Reply
#4

OnGameModeInit:
SetTimer("CheckServerWeapons", 1000, true);

Remove "CheckServerWeapons(playerid);" from OnPlayerUpdate.

And change the CheckServerWeapons(playerid) to CheckServerWeapons(), then replace callback with this;
pawn Код:
forward CheckServerWeapons();
public CheckServerWeapons()
{
    foreach(Player, playerid)
    {
        new weaponid = GetPlayerWeapon(playerid);

        if(weaponid >= 1 && weaponid <= 15)
        {
            if(weaponid == ServerWeapons[playerid][Melee])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a melee weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1); // ABroadCast Is same as send client message but only sends to admins
                }
        }

            if( weaponid >= 16 && weaponid <= 18 || weaponid == 39 ) // Checking Thrown
        {
            if(weaponid == ServerWeapons[playerid][Thrown])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Thrown weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid >= 22 && weaponid <= 24 ) // Checking Pistols
        {
            if(weaponid == ServerWeapons[playerid][Pistols])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Pistol.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid >= 25 && weaponid <= 27 ) // Checking Shotguns
        {
            if(weaponid == ServerWeapons[playerid][Shotguns])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Shotgun.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid == 28 || weaponid == 29 || weaponid == 32 ) // Checking Sub Machine Guns
        {
            if(weaponid == ServerWeapons[playerid][SubMachine])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Sub machine gun weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid == 30 || weaponid == 31 ) // Checking Assault
        {
            if(weaponid == ServerWeapons[playerid][Assault])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Assault weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid == 33 || weaponid == 34 ) // Checking Rifles
        {
            if(weaponid == ServerWeapons[playerid][Rifles])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Rifle.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid >= 35 && weaponid <= 38 ) // Checking Heavy
        {
            if(weaponid == ServerWeapons[playerid][Heavy])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a heavy weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        else { return 1; }
    }
    return 1;
}
Reply
#5

double post
Reply
#6

Thanks , will test this.
Reply
#7

Quote:
Originally Posted by cosbraa
Посмотреть сообщение
OnGameModeInit:
SetTimer("CheckServerWeapons", 1000, true);

Remove "CheckServerWeapons(playerid);" from OnPlayerUpdate.

And change the CheckServerWeapons(playerid) to CheckServerWeapons(), then replace callback with this;
pawn Код:
forward CheckServerWeapons();
public CheckServerWeapons()
{
    foreach(Player, playerid)
    {
        new weaponid = GetPlayerWeapon(playerid);

        if(weaponid >= 1 && weaponid <= 15)
        {
            if(weaponid == ServerWeapons[playerid][Melee])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a melee weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1); // ABroadCast Is same as send client message but only sends to admins
                }
        }

            if( weaponid >= 16 && weaponid <= 18 || weaponid == 39 ) // Checking Thrown
        {
            if(weaponid == ServerWeapons[playerid][Thrown])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Thrown weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid >= 22 && weaponid <= 24 ) // Checking Pistols
        {
            if(weaponid == ServerWeapons[playerid][Pistols])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Pistol.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid >= 25 && weaponid <= 27 ) // Checking Shotguns
        {
            if(weaponid == ServerWeapons[playerid][Shotguns])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Shotgun.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid == 28 || weaponid == 29 || weaponid == 32 ) // Checking Sub Machine Guns
        {
            if(weaponid == ServerWeapons[playerid][SubMachine])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Sub machine gun weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid == 30 || weaponid == 31 ) // Checking Assault
        {
            if(weaponid == ServerWeapons[playerid][Assault])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Assault weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }

        if( weaponid == 33 || weaponid == 34 ) // Checking Rifles
        {
            if(weaponid == ServerWeapons[playerid][Rifles])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a Rifle.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        if( weaponid >= 35 && weaponid <= 38 ) // Checking Heavy
        {
            if(weaponid == ServerWeapons[playerid][Heavy])
            {
            return 1;
            }
                else
                {
                new sendername[ MAX_PLAYER_NAME ];
                new string[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, 128, "AdmWarn: %s has possibly hacked a heavy weapon.", sendername);
                ABroadCast(COLOR_YELLOW, string, 1);
                }
        }
        else { return 1; }
    }
    return 1;
}
he doesn't have foreach (i think)
Reply
#8

I do have it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)