SA-MP Forums Archive
AFK System. - 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)
+--- Thread: AFK System. (/showthread.php?tid=375088)



AFK System. - fuem1907 - 05.09.2012

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.


Re: AFK System. - shaniyal - 05.09.2012

i got,but its not an afk system


Re: AFK System. - RanSEE - 05.09.2012

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