(HELP) AFK
#1

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;
}
Reply
#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
#3

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;
}
}
Reply
#4

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 ?
Reply
#5

Yeah, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)