[AFK System] need help
#6

or try this!
Код:
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!
        }
    }
}
Код:
format(string, sizeof(string), "%s(%i) has been away from keyboard for %d seconds.", PlayerName, playerid, AFK[playerid]);
SendClientMessageToAll(-1, string);
Reply


Messages In This Thread
[AFK System] need help - by JeroenX - 08.04.2012, 15:10
Re: [AFK System] need help - by Plastic - 08.04.2012, 15:18
Re: [AFK System] need help - by .FuneraL. - 08.04.2012, 16:37
Re: [AFK System] need help - by JeroenX - 08.04.2012, 21:19
Re: [AFK System] need help - by [EuG]ZeRoGoD - 08.04.2012, 21:50
Re: [AFK System] need help - by [EuG]ZeRoGoD - 08.04.2012, 21:56

Forum Jump:


Users browsing this thread: 1 Guest(s)