Player Pause
#1

I decided to return to scripting, and work on my script from scratch, The problem is I was planning to use the OnPlayerPause include, but the topic was removed for some reason, may someone give me a direct link for it, thank you very much in advance.
Reply
#2

you could just make your own, set a variable under onplayerupdate and run a one second timer to decrease that variable.
since onplayerupdate isn't called when a player is paused the variable would only go down if they were paused
Reply
#3

I haven't scripted in some time, but I do believe this is the quickest method.

pawn Код:
forward checkPlayerUpdates();
new pLastUpdate[MAX_PLAYERS];
new pLostFocus[MAX_PLAYERS];
public OnGameModeInit()
{
    SetTimer("checkPlayerUpdates",1000,1);
}
public checkPlayerUpdates()
{
    new currentTime;
    for(new playerid;playerid<MAX_PLAYERS;playerid++)
    {
        if(!IsPlayerConnected(playerid))continue;
        currentTime=GetTickCount();
        if(currentTime-1000>pLastUpdate[playerid])pLostFocus[playerid]=1;
        else pLostFocus[playerid]=0;
    }
}
public OnPlayerUpdate(playerid)
{
    pLastUpdate[playerid]=GetTickCount();
    return 1;
}
pLostFocus[ playerID ] will then contain a 1/0 if the player is tabbed out or paused.
Take note that the player will be considered tabbed out or paused until he spawns (OnPlayerUpdate is not called until the player spawns). To fix this issue add this

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate==PLAYER_STATE_SPAWNED)pLastUpdate[playerid]=GetTickCount();
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)