detect if player doesn't move for x seconds?
#8

PHP код:
OnGamemodeInit()...
    
SetTimer("CheckAFK"800true);

PUBLIC:
CheckAFK()
{
    foreach(new 
Player)
    {
        if(
gettime() - AFKDetect[i] > && !IsPlayerAFK[i])
        {
            
IsPlayerAFK[i] = true;
            
TogglePlayerControllable(ifalse);
            
SCMTAE(RED"%s is now AFK."GetName(i));
        }
        else if(
gettime() - AFKDetect[i] < && IsPlayerAFK[i])
        {
            
IsPlayerAFK[i] = false;
            
TogglePlayerControllable(itrue);
            
SCMTAE(RED"%s is not anymore AFK."GetName(i));
        }
    }
    return 
1;
}

OnPlayerUpdate()..
AFKDetect[playerid] = gettime(); 
I don't really now if it's optimized. ;p
Reply


Messages In This Thread
detect if player doesn't move for x seconds? - by Bondz - 04.11.2016, 05:51
Re: detect if player doesn't move for x seconds? - by VVWVV - 04.11.2016, 06:28
Re: detect if player doesn't move for x seconds? - by Hansrutger - 04.11.2016, 06:32
Re: detect if player doesn't move for x seconds? - by Bondz - 04.11.2016, 07:04
Re: detect if player doesn't move for x seconds? - by Micko123 - 04.11.2016, 07:07
Re: detect if player doesn't move for x seconds? - by Threshold - 04.11.2016, 07:52
Re: detect if player doesn't move for x seconds? - by Micko123 - 04.11.2016, 08:13
Re: detect if player doesn't move for x seconds? - by Dayrion - 04.11.2016, 09:07

Forum Jump:


Users browsing this thread: 1 Guest(s)