pawn Код:
//On the top of your script
new AFK[MAX_PLAYERS];
new AFKTimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
AFK[playerid] = 0;
KillTimer(AFKTimer[playerid]);
AFKTimer[playerid] = SetTimerEx("AFKCheck",1000,1,"i",playerid);
}
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
if(!IsPlayerConnected(playerid) || pData[ playerid ][ P_LEVEL ] >= _:P_LEVEL_MOD || IsPlayerAdmin( playerid ))
{
AFK[playerid] = 0;
KillTimer(AFKTimer[playerid]);
return;
}
if(++AFK[playerid] >= 60) // if player is min 60 sec afk - kick
{
AFK[playerid] = 0;
KillTimer(AFKTimer[playerid]);
new pName[MAX_PLAYER_NAME],string[120];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), ">> Admin kick d %s for the reason: max time afk", pName );
SendClientMessageToAll(COLOR_ORANGE, string);
format(string, sizeof(string), "you are kicked for afk." );
SendClientMessage( playerid, COLOR_RED, string);
printf( "( %s ) (ID:%d) kicked afk", pName, playerid );
SetTimerEx("KickPlayer",500,false,"i",playerid );
}
}
public OnPlayerUpdate(playerid)
{
AFK[playerid] = 0;
return 1;
}