Auto-AFK kick and Ping Kick
#1

Can someone make a tutorial on how to make your own Auto-AFK kick system and Ping kick system?
Reply
#2

You could just set a timer, that checks every 10 minutes the coordinates of every player and if a player has the same coordinates in two checks he gets kicked...
Reply
#3

On Top of ur script:
pawn Код:
#define PING_MAX_EXCEEDS 4
#define PING_TIMELIMIT 60 // SECONDS
pawn Код:
forward BotCheck(playerid);
public BotCheck(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(GetPlayerPing(playerid) < 1)
        {
            new string[128], ip[20];  GetPlayerIp(playerid,ip,sizeof(ip));
            format(string,sizeof(string),"BOT: %s id:%d ip: %s ping: %d",PlayerName2(playerid),playerid,ip,GetPlayerPing(playerid));
            printf("[ADMIN] Possible bot has been detected (Kicked %s ID:%d)", PlayerName2(playerid), playerid);
            Kick(playerid);
        }
    }
}

forward PingKick();
public PingKick()
{
    if(ServerInfo[MaxPing] != 0)
    {
        PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;
       
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);
           
            if(GetPlayerPing(i) > ServerInfo[MaxPing])
            {
                if(PlayerInfo[i][PingCount] == 0) PlayerInfo[i][PingTime] = TimeStamp();

                PlayerInfo[i][PingCount]++;
                if(TimeStamp() - PlayerInfo[i][PingTime] > PING_TIMELIMIT)
                {
                    PlayerInfo[i][PingTime] = TimeStamp();
                    PlayerInfo[i][PingCount] = 1;
                }
                else if(PlayerInfo[i][PingCount] >= PING_MAX_EXCEEDS)
                {
                    new Sum, Average, x, string[128];
                    while (x < PING_MAX_EXCEEDS) {
                        Sum += PlayerInfo[i][pPing][x];
                        x++;
                    }
                    Average = (Sum / PING_MAX_EXCEEDS);
                    format(string,sizeof(string),"%s has been kicked from the server. (Reason: High Ping (%d) | Average (%d) | Max Allowed (%d) )", PlayerName2(i), GetPlayerPing(i), Average, ServerInfo[MaxPing] );
                    SendClientMessageToAll(grey,string);
                    SaveToFile("KickLog",string);
                    Kick(i);
                }
            }
            else if(GetPlayerPing(i) < 1 && ServerInfo[AntiBot] == 1)
            {
                PlayerInfo[i][BotPing]++;
                if(PlayerInfo[i][BotPing] >= 3) BotCheck(i);
            }
            else
            {
                PlayerInfo[i][BotPing] = 0;
            }
        }
    }

stock TimeStamp()
{
    new time = GetTickCount() / 1000;
    return time;
}

stock PlayerName2(playerid) {
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  return name;
}
pawn Код:
enum ServerData
{
    MaxPing,
        AntiBot,
};
new ServerInfo[ServerData];
//and:
enum PlayerData
{
        PingCount,
    PingTime,
    BotPing,
    pPing[PING_MAX_EXCEEDS],
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
OnGameModeInIt/OnFilterScriptInIT:
pawn Код:
PingTimer = SetTimer("PingKick",5000,1);
Reply
#4

Quote:
Originally Posted by selten98
Посмотреть сообщение
On Top of ur script:
pawn Код:
#define PING_MAX_EXCEEDS 4
#define PING_TIMELIMIT 60 // SECONDS
pawn Код:
forward BotCheck(playerid);
public BotCheck(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(GetPlayerPing(playerid) < 1)
        {
            new string[128], ip[20];  GetPlayerIp(playerid,ip,sizeof(ip));
            format(string,sizeof(string),"BOT: %s id:%d ip: %s ping: %d",PlayerName2(playerid),playerid,ip,GetPlayerPing(playerid));
            printf("[ADMIN] Possible bot has been detected (Kicked %s ID:%d)", PlayerName2(playerid), playerid);
            Kick(playerid);
        }
    }
}

forward PingKick();
public PingKick()
{
    if(ServerInfo[MaxPing] != 0)
    {
        PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;
       
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);
           
            if(GetPlayerPing(i) > ServerInfo[MaxPing])
            {
                if(PlayerInfo[i][PingCount] == 0) PlayerInfo[i][PingTime] = TimeStamp();

                PlayerInfo[i][PingCount]++;
                if(TimeStamp() - PlayerInfo[i][PingTime] > PING_TIMELIMIT)
                {
                    PlayerInfo[i][PingTime] = TimeStamp();
                    PlayerInfo[i][PingCount] = 1;
                }
                else if(PlayerInfo[i][PingCount] >= PING_MAX_EXCEEDS)
                {
                    new Sum, Average, x, string[128];
                    while (x < PING_MAX_EXCEEDS) {
                        Sum += PlayerInfo[i][pPing][x];
                        x++;
                    }
                    Average = (Sum / PING_MAX_EXCEEDS);
                    format(string,sizeof(string),"%s has been kicked from the server. (Reason: High Ping (%d) | Average (%d) | Max Allowed (%d) )", PlayerName2(i), GetPlayerPing(i), Average, ServerInfo[MaxPing] );
                    SendClientMessageToAll(grey,string);
                    SaveToFile("KickLog",string);
                    Kick(i);
                }
            }
            else if(GetPlayerPing(i) < 1 && ServerInfo[AntiBot] == 1)
            {
                PlayerInfo[i][BotPing]++;
                if(PlayerInfo[i][BotPing] >= 3) BotCheck(i);
            }
            else
            {
                PlayerInfo[i][BotPing] = 0;
            }
        }
    }

stock TimeStamp()
{
    new time = GetTickCount() / 1000;
    return time;
}

stock PlayerName2(playerid) {
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  return name;
}
pawn Код:
enum ServerData
{
    MaxPing,
        AntiBot,
};
new ServerInfo[ServerData];
//and:
enum PlayerData
{
        PingCount,
    PingTime,
    BotPing,
    pPing[PING_MAX_EXCEEDS],
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
OnGameModeInIt/OnFilterScriptInIT:
pawn Код:
PingTimer = SetTimer("PingKick",5000,1);
-EDIT-
Nevermind
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)