public AFK(playerid) { GetPlayerPos(playerid, Posiciones[playerid][0], Posiciones[playerid][1], Posiciones[playerid][2]); if(Posiciones[playerid][0] == Posiciones[playerid][3] && Posiciones[playerid][1] == Posiciones[playerid][4] && Posiciones[playerid][2] == Posiciones[playerid][5]) { if(EstaAFK[playerid] == 0) { 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 ); return 1; } else { Posiciones[playerid][3] = Posiciones[playerid][0]; Posiciones[playerid][4] = Posiciones[playerid][1]; Posiciones[playerid][5] = Posiciones[playerid][2]; KillTimer(TAFK[playerid]); TAFK[playerid] = SetTimerEx("AFK", TIEMPO, 1, "i", playerid); return 1; } } else { Posiciones[playerid][3] = Posiciones[playerid][0]; Posiciones[playerid][4] = Posiciones[playerid][1]; Posiciones[playerid][5] = Posiciones[playerid][2]; KillTimer(TAFK[playerid]); TAFK[playerid] = SetTimerEx("AFK", TIEMPO, 1, "i", playerid); return 1; } }
if ( pData[ playerid ][ P_LEVEL ] >= _:P_LEVEL_MOD || IsPlayerAdmin( playerid ) )
//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;
}
Outdated afk system, do it by this
https://sampforum.blast.hk/showthread.php?tid=479616 pawn Код:
|