16.07.2011, 09:32
Please, how can I add message: "you are AFK now" after one minute of afk in this script? THX
pawn Код:
public OnFilterScriptInit()
{
SetTimer("AFKKicker", 60000, 1);
return 1;
}
forward AFKKicker();
new Float:PPos[MAX_PLAYERS][3];
new AFKMins[MAX_PLAYERS];
new show = ShowTime;
new pub = Public;
public OnPlayerConnect(playerid)
{
PPos[playerid][0] = 0;
PPos[playerid][1] = 0;
PPos[playerid][2] = 0;
AFKMins[playerid] = 0;
}
public AFKKicker()
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(PPos[i][1] == 0)
{
GetPlayerPos(i,PPos[i][0],PPos[i][1],PPos[i][2]);
return 1;
}
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
{
AFKMins[i]++;
if(AFKMins[i] >= AFKTime)
{
if(show == 1)
{
new string[128];
format(string, sizeof(string), "You have been auto kicked(AFK)(%d minutes)",AFKTime);
SendClientMessage(i,0xAA3333AA,string);
}
else
{
SendClientMessage(i, 0xAA3333AA,"You were Away From Keyboard(AFK)");
}
Kick(i);
if(pub == 1)
{
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s was kicked for being AFK too long",name);
SendClientMessageToAll(0xAA3333AA,string);
}
}
}
}
return 1;
}