How To Create a Auto Afk system?
#4

pawn Код:
new AFK[MAX_PLAYERS];

// ...

public OnGameModeInit()
{
    // Run a timer here
    SetTimer("CheckAFK", 1000, true);
}

// ...

public OnPlayerUpdate(playerid)
{
    // If the player just came back from being afk, the AFK variable is most likely more than 3/5 (vary this based on your gamemode and experience)
    if(AFK[playerid] > 3)
    {
         // This player just came back from being AFK
    }
    AFK[playerid] = 0;
}

// ...

forward CheckAFK();
public CheckAFK()
{
    // Suggestions for loop: either use foreach or at least define MAX_PLAYERS to your server's server.cfg amount!
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;

        AFK[i] ++;
        if(AFK[i] == 3)
        {
            // The player most likely just went AFK!
        }
    }
}
Reply


Messages In This Thread
How To Create a Auto Afk system? - by Torus - 01.05.2012, 09:44
Re: How To Create a Auto Afk system? - by Faisal_khan - 01.05.2012, 09:51
Re: How To Create a Auto Afk system? - by Torus - 01.05.2012, 09:54
Re: How To Create a Auto Afk system? - by Faisal_khan - 01.05.2012, 09:59
Re: How To Create a Auto Afk system? - by Torus - 01.05.2012, 10:17
Re: How To Create a Auto Afk system? - by Faisal_khan - 02.05.2012, 07:46
Re: How To Create a Auto Afk system? - by Gamer_007 - 06.07.2012, 09:34
Re: How To Create a Auto Afk system? - by Faisal_khan - 08.07.2012, 08:40

Forum Jump:


Users browsing this thread: 1 Guest(s)