Afk on esc
#3

This detects if a player pauses their game with ESC or ALT + TAB.

pawn Код:
new bool:PlayerPaused[MAX_PLAYERS] = false,
InactiveTime[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("CheckForPausedPlayers", 1000, true);
    return 1;
}

public OnPlayerUpdate(playerid)
{  
    if(InactiveTime[playerid] >= 5) PlayerPaused[playerid] = false; // Player has unpaused their game.
    InactiveTime[playerid] = 0;
    return 1;
}

forward CheckForPausedPlayers();
public CheckForPausedPlayers()
{
    foreach(new i: Player)
    {
        if(PlayerPaused[i] == false)
        {
            InactiveTime[i] ++;
            if(InactiveTime[i] == 5)
            {
                PlayerPaused[i] = true; // Player has paused their game.
            }
        }
    }
}
Reply


Messages In This Thread
Afk on esc - by youssefehab500 - 03.08.2014, 01:22
Re: Afk on esc - by youssefehab500 - 03.08.2014, 03:21
Re: Afk on esc - by SickAttack - 03.08.2014, 04:32
Re: Afk on esc - by youssefehab500 - 03.08.2014, 04:38

Forum Jump:


Users browsing this thread: 1 Guest(s)