(HELP) AFK
#2

Like this:

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] == 1)
            {
                SendClientMessage(i, -1, "You are now AFK !");
            }
            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);
                }
            }
        }
        else
        {
            if(AFKMins[i])
            {
                SendClientMessage(i, -1, "You are no longer AFK !");
                AFKMins[i] = 0;
            }
        }
    }
    return 1;
}
But your code is not actually good. I don't see where you reset the AFK Variables, after player is not longer AFK ...
Reply


Messages In This Thread
(HELP) AFK - by spaty2 - 16.07.2011, 09:32
Re: (HELP) AFK - by MoroDan - 16.07.2011, 09:35
Re: (HELP) AFK - by Skaizo - 16.07.2011, 09:37
Re: (HELP) AFK - by MoroDan - 16.07.2011, 09:39
Re: (HELP) AFK - by spaty2 - 16.07.2011, 09:40

Forum Jump:


Users browsing this thread: 1 Guest(s)