16.08.2011, 15:26
pawn Код:
new bool:Afk[MAX_PLAYERS];
new AfkTimer[MAX_PLAYERS];
new Float:LastPos[MAX_PLAYERS][3];
forward SetPlayerAfk(playerid);
public OnPlayerConnect(playerid)
{
Afk[playerid] = false;
AfkTimer[playerid] = SetTimerEx("SetPlayerAfk",10000,1,"d",playerid);//10 seconds?
}
public OnPlayerDisconnect(playerid,reason)
{
KillTimer(AFKTimer[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
GetPlayerPos(playerid,LastPos[playerid][0],LastPos[playerid][1],LastPos[playerid][2]);
return 1;
}
public SetPlayerAfk(playerid)
{
new Float:Pos[3];
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
if(Pos[0] == LastPos[playerid][0] && Pos[1] == LastPos[playerid][1] && Pos[2] == LastPos[playerid][2])
{
SendClientMessage(playerid, 0xFFFFFF, "You are AFK.");
Afk[playerid] = true;
}
else
{
Pos[0] = LastPos[playerid][0];
Pos[1] = LastPos[playerid][1];
Pos[2] = LastPos[playerid][2];
}
return 1;
}