Detect back windows?
#10

Quote:
Originally Posted by wups
Посмотреть сообщение
Yeah, the best bet would be to check the TickCount on every PlayerUpdate.
That would perhaps be the most accurate method, but why seek millisecond-specific accuracy when detecting someone's AFK status (I mean, consider the player to be afk when they've not sent an update for 3 seconds rather than 2568 milliseconds ).

And in fact the method that tyler posted does work, but not the best. What I've considered to be the best solution so far is have a variable that is incremented in a timer and set to zero in OnPlayerUpdate.

pawn Код:
new NoUpdateFor[MAX_PLAYERS];

// OnGameModeInit()
SetTimer("IncrementAFK", 1000, true);

// IncrementAFK()
foreach(Player, i)
{
    NoUpdateFor[i] ++;
}

// OnPlayerUpdate(playerid)
NoUpdateFor[i] = 0;

// IsPlayerNotSendingUpdates(playerid)
return (NoUpdateFor[playerid] > 3);
This method has an upside of its own: you can specify how long the player has been alt tabbed for (the value of seconds is stored in NoUpdateFor[playerid]). Also it does not run any very large calculations so it should be the best suitable option for using in OnPlayerUpdate as well.
Reply


Messages In This Thread
Detect back windows? - by scott1 - 31.01.2013, 17:25
Re: Detect back windows? - by wups - 31.01.2013, 17:30
Re: Detect back windows? - by Gforcez - 31.01.2013, 17:33
Re: Detect back windows? - by FufLa - 31.01.2013, 17:36
Re: Detect back windows? - by Rapgangsta - 31.01.2013, 17:45
Re: Detect back windows? - by tyler12 - 31.01.2013, 17:48
Re: Detect back windows? - by Cypress - 31.01.2013, 17:51
Re: Detect back windows? - by wups - 31.01.2013, 18:02
Re : Re: Detect back windows? - by scott1 - 31.01.2013, 18:26
Re: Detect back windows? - by AndreT - 01.02.2013, 09:26

Forum Jump:


Users browsing this thread: 1 Guest(s)