Questions about AFK -
Ezzz - 03.07.2018
How do you determine if the player is in an AFK state and what I mean by AFK here is by pressing the ESC key or cutting out the game please call me back or the function
I am a Chinese. Maybe my English is not very good. Please understand that the samp in China is about to stop running
thanks!
Re: Questions about AFK -
Ezzz - 03.07.2018
I mean is
How to check whether the player is in AFK state
There are no relative functions or callbacks
Re: Questions about AFK -
Sew_Sumi - 03.07.2018
That's not AFK, that's Alt-Tabbed. OnPlayerUpdate doesn't get updated when the player is tabbed. But because of it's nature, bad internet can also cause packet-loss which will also not update OnPlayerUpdate.
This has been asked so many times before.
Re: Questions about AFK -
Ezzz - 07.07.2018
So how do you detect a player in alt-tabbed?
Re: Questions about AFK -
Sew_Sumi - 07.07.2018
https://sampforum.blast.hk/showthread.php?tid=281590
AFK is more sitting idle, in a car, or in a house not moving.
Alt-tabbed is in the menu/map, out in other apps.
packet loss, and a bad connection can cause the alt-tabbed scenario to trigger, as it's dropping packets and hence not having OnPlayerUpdate call as much as it should. This include likely copes with this.
Re: Questions about AFK -
Kane - 07.07.2018
Checking if a player is alt tabbed is pretty simple.
Make two variables.
PHP код:
new
gPauseUpdate[ MAX_PLAYERS ],
gIdleTime[ MAX_PLAYERS ]
;
OnPlayerUpdate -
PHP код:
public OnPlayerUpdate( playerid )
{
gPauseUpdate[ playerid ] = GetTickCount( );
return 1;
}
You'll need a one second timer.
PHP код:
public OnClientSecond()
{
for( new playerid; playerid < MAX_PLAYERS; playerid++ )
{
if( !IsPlayerConnected( playerid ) ) {
continue;
}
if( GetTickCount( ) > ( gPauseUpdate[ playerid ] + 3000 ) ) {
gIdleTime[ playerid ] ++;
} else if( gIdleTime[ playerid ] ) gIdleTime[ playerid ] = 0;
}
return 1;
}
Re: Questions about AFK -
Sew_Sumi - 07.07.2018
^^ This is pretty good, for finding the tabbed players.
Just remember it will pick up people with bad connections, and people who are looking at the map.
Re: Questions about AFK -
Ezzz - 07.07.2018
Thank you all