[FilterScript] Pause check
#2

Okay that is just PLAIN HORRIBLE.

You should definitely not use PVars in OnPlayerUpdate. And actually you don't even need GetTickCount().

What you should do to detect AFKing is:
1. in OnPlayerUpdate, keep setting a variable to 0
2. in your 1-second timer, keep incrementing the variable until it reaches 2. If it reaches 2, the player is not sending updates anymore (is paused, about to time out, whatever)

pawn Код:
new updating[MAX_PLAYERS char];

public OnGameModeInit()
{
    SetTimer("checkAFK", 1000, true);
}

public OnPlayerUpdate(playerid)
{
    updating{playerid} = 0;
}

forward checkAFK();
public checkAFK()
{
    foreach(Player, i)
    {
        if(updating{i} < 2)
            updating{i} ++;
        else
        {
            // Player went AFK!
        }
    }
}
Basic but you get the idea.
Reply


Messages In This Thread
Pause check - by GameStar. - 18.08.2011, 22:30
Re: Pause check - by AndreT - 18.08.2011, 22:38
Re: Pause check - by GameStar. - 18.08.2011, 23:05
Re: Pause check - by Davz*|*Criss - 18.08.2011, 23:38
Re: Pause check - by AndreT - 19.08.2011, 09:01
Re: Pause check - by System64 - 19.08.2011, 09:22
Respuesta: Pause check - by predator_ - 23.08.2011, 22:30
Re: Pause check - by Gh0sT_ - 23.08.2011, 23:53
Re: Pause check - by Ivan_Pantovic - 24.08.2011, 00:08
Re: Pause check - by ••• ĤБĶБM ••• - 24.08.2011, 01:05

Forum Jump:


Users browsing this thread: 2 Guest(s)