SA-MP Forums Archive
(HELP) AFK - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: (HELP) AFK (/showthread.php?tid=269380)



(HELP) AFK - spaty2 - 16.07.2011

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;
}



Re: (HELP) AFK - MoroDan - 16.07.2011

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 ...


Re: (HELP) AFK - Skaizo - 16.07.2011

public OnFilterScriptInit()
{
for(new i; i<MAX_PLAYERS; i++)
{
new pName[MAX_PLAYERS]
printf("%s is afk now", pName);
SetTimer("AFKKicker", 60000, 1);
return 1;
}
}


Re: (HELP) AFK - MoroDan - 16.07.2011

Quote:
Originally Posted by Skaizo
Посмотреть сообщение
public OnFilterScriptInit()
{
for(new i; i<MAX_PLAYERS; i++)
{
new pName[MAX_PLAYERS]
printf("%s is afk now", pName);
SetTimer("AFKKicker", 60000, 1);
return 1;
}
}
What the f**k is this ?! Are you kiddin' me ?


Re: (HELP) AFK - spaty2 - 16.07.2011

Yeah, thank you.