AFK System.
#1

Hello there, I need a system which will kick player who stayed 5min without moving. Basically it'll kick AFK people. If you don't move in 5 min, you'll get auto-kicked. Thanks from now.
Reply
#2

i got,but its not an afk system
Reply
#3

pawn Код:
new AfkCount[MAX_PLAYERS]; //<-- this will be our player variable for checking any AFK'ers.
stock IsPlayerAfk(playerid) return (AfkCount[playerid] > 1); //<-- usefull to check if the player is afk/desynced or not
public OnGameModeInit()
//..or
public OnFilterScriptInit()
{
    SetTimer("SlowTick", 500, true); //<- our timer to increase the amount of our player variables.
    return 1;
}
forward SlowTick();
public SlowTick()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) //<-- our player loop
    {
        if(!IsPlayerConnected(playerid)) continue; //<-- if not connected.. just check the next ID
        AfkCount[playerid]++; //<-- adds always +1;
    }
}
public OnPlayerConnect(playerid)
{
    AfkCount[playerid] = 0; //resets after player login
    return 1;
}
public OnPlayerUpdate(playerid)
{
    AfkCount[playerid] = 0; //Resets after every player update (happens only if the player is not afk)
    return 1;
}
Credits to Bigeti
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)