Help whit this code
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Outdated afk system, do it by this

https://sampforum.blast.hk/showthread.php?tid=479616

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;
}
Thank you!!
Reply


Messages In This Thread
Help whit this code - by Guss - 10.03.2015, 02:14
Re: Help whit this code - by Jefff - 10.03.2015, 02:29
Respuesta: Re: Help whit this code - by Guss - 10.03.2015, 03:34

Forum Jump:


Users browsing this thread: 1 Guest(s)