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(playerid, newpos[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(playerid, newpos[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", 1000, true, "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