Is it possible to auto kick paused players without using onplayerupdate?
#9

Quote:
Originally Posted by BenzoAMG
View Post
Well you wanted something that wasn't called 3052 or whatever times a second, so there... be happy with it.
This is completely inaccurate, if you're going to try to help at least post something useful.

OnPlayerUpdate is called every time a client updates with the server, so depending on if the player is doing something (moving etc) it will be called more or less, it's not something to avoid almost like it's the plague but you shouldn't pack it full of stuff.

One way to make a detection to see if a player is paused is like this.

Define these global variables...

pawn Code:
new PlayerPaused[MAX_PLAYERS], pausetick[MAX_PLAYERS];
In OnPlayerUpdate, add this...

pawn Code:
pausetick[playerid] = GetTickCount();
Now, in OnGameModeInit start a repeating timer for 1 second, or if you already have a 1 second repeating timer, skip to the next step.

pawn Code:
SetTimer("PauseCheck", 1000, 1);
Now add this public function.

pawn Code:
forward PauseCheck();
public PauseCheck()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(playerid)) continue;
        if(GetTickCount() - pausetick[i] > 1000) // If they haven't updated in 1+ seconds, increase if needed.
        {
            PlayerPaused[i] = 1;
        }
        else
        {
            PlayerPaused[i] = 0;
        }
    }
    return 1;
}
Now, when someone pauses it should set PlayerPaused to 1 after 1 second, if they unpause it gets set to 0 after 1 second.

I'm pretty sure you can take it from here to make an AFK kicker now that you have this pause detector.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)