Questions about AFK
#1

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!
Reply
#2

I mean is
How to check whether the player is in AFK state
There are no relative functions or callbacks
Reply
#3

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.
Reply
#4

So how do you detect a player in alt-tabbed?
Reply
#5

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.
Reply
#6

Checking if a player is alt tabbed is pretty simple.

Make two variables.
PHP код:
new 
    
gPauseUpdateMAX_PLAYERS ],
    
gIdleTimeMAX_PLAYERS ]

OnPlayerUpdate -
PHP код:
public OnPlayerUpdateplayerid )
{
    
gPauseUpdateplayerid ] = GetTickCount( );
    return 
1;

You'll need a one second timer.
PHP код:
public OnClientSecond()
{
    for( new 
playeridplayerid MAX_PLAYERSplayerid++ )
    {
        if( !
IsPlayerConnectedplayerid ) ) {
            continue;
        }
        if( 
GetTickCount( ) > ( gPauseUpdateplayerid ] + 3000 ) ) {
            
gIdleTimeplayerid ] ++;
        } else if( 
gIdleTimeplayerid ] ) gIdleTimeplayerid ] = 0;
    }
    return 
1;

Reply
#7

^^ 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.
Reply
#8

Thank you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)