07.07.2018, 04:28
Checking if a player is alt tabbed is pretty simple.
Make two variables.
OnPlayerUpdate -
You'll need a one second timer.
Make two variables.
PHP код:
new
gPauseUpdate[ MAX_PLAYERS ],
gIdleTime[ MAX_PLAYERS ]
;
PHP код:
public OnPlayerUpdate( playerid )
{
gPauseUpdate[ playerid ] = GetTickCount( );
return 1;
}
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;
}