AFK system help
#2

Quote:
Originally Posted by Method 1
PHP код:
#include <YSI/y_timers>
new Float:lastpos[MAX_PLAYERS][3];
new 
afk_strike[MAX_PLAYERS];
ptask IsAFK[1000](playerid)
{
    if(
Is_AFK[playerid] == false)
    {
        new 
Float:newpos[3];
        
GetPlayerPos(playeridnewpos[0], newpos[1], newpos[2]);
        if(
newpos[0] == lastpos[0] && newpos[1] == lastpos[1] && newpos[2] == lastpos[2])
        {
            
afk_strike++;
            if(!(
afk_strike 30))
            {
                
PutHimInAFK(playerid);
            }
        }
        else
            
afk_strike 0;
    }
    return 
1;

Quote:
Originally Posted by Method 2
PHP код:
new Float:lastpos[MAX_PLAYERS][3];
new 
afk_strike[MAX_PLAYERS];
forward IsAFK(playerid);
public 
IsAFK(playerid)
{
    if(
Is_AFK[playerid] == false)
    {
        new 
Float:newpos[3];
        
GetPlayerPos(playeridnewpos[0], newpos[1], newpos[2]);
        if(
newpos[0] == lastpos[0] && newpos[1] == lastpos[1] && newpos[2] == lastpos[2])
        {
            
afk_strike++;
            if(!(
afk_strike 30))
            {
                
PutHimInAFK(playerid);
            }
        }
        else
            
afk_strike 0;
    }
    return 
1;
}
new 
TimerID[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
TimerID[playerid] = SetTimer("IsAFK"1000true"i"playerid);
}
public 
OnPlayerDisconnect(playerid)
{
    
KillTimer(TimerID[playerid]);

Use any of the above to check if a player is standing Idle.. Clear variables on Disconnect/Connect
Reply


Messages In This Thread
AFK system help - by silverms - 09.02.2017, 11:54
Re: AFK system help - by Mic_H - 09.02.2017, 12:43

Forum Jump:


Users browsing this thread: 1 Guest(s)