How To Create a Auto Afk system?
#1

Guys I have seen many servers using auto afk system and i always try / wonder how they made it.I tryed to make one but it was not working atlast i gave up and i wanna ask here how to make it?. If Some one helps me it will +1 rep and i will be very thkfull to him.

sorry i forgot to mention that without any cmd i mean when the player press esc then he gets afk and when hes back from afk and moves then hes back
Reply
#2

Here have it:
pawn Код:
if (strcmp("/back", cmdtext, true, 4) == 0)
    {
        TogglePlayerControllable(playerid,1);
        SendClientMessage(playerid,COLOR_PINK,"You are not AFK Anymore !");
        return 1;
    }
    if (strcmp("/afk", cmdtext, true, 3) == 0)
    {
        TogglePlayerControllable(playerid,0);
        SendClientMessage(playerid,COLOR_PINK,"You are now AFK!");
        return 1;
    }
Reply
#3

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
Here have it:
pawn Код:
if (strcmp("/back", cmdtext, true, 4) == 0)
    {
        TogglePlayerControllable(playerid,1);
        SendClientMessage(playerid,COLOR_PINK,"You are not AFK Anymore !");
        return 1;
    }
    if (strcmp("/afk", cmdtext, true, 3) == 0)
    {
        TogglePlayerControllable(playerid,0);
        SendClientMessage(playerid,COLOR_PINK,"You are now AFK!");
        return 1;
    }
No dude i meant auto afk without any commands when the player press esc that time i meant
Reply
#4

pawn Код:
new AFK[MAX_PLAYERS];

// ...

public OnGameModeInit()
{
    // Run a timer here
    SetTimer("CheckAFK", 1000, true);
}

// ...

public OnPlayerUpdate(playerid)
{
    // If the player just came back from being afk, the AFK variable is most likely more than 3/5 (vary this based on your gamemode and experience)
    if(AFK[playerid] > 3)
    {
         // This player just came back from being AFK
    }
    AFK[playerid] = 0;
}

// ...

forward CheckAFK();
public CheckAFK()
{
    // Suggestions for loop: either use foreach or at least define MAX_PLAYERS to your server's server.cfg amount!
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;

        AFK[i] ++;
        if(AFK[i] == 3)
        {
            // The player most likely just went AFK!
        }
    }
}
Reply
#5

Thanks REPPED!
Reply
#6

Quote:
Originally Posted by Torus
Посмотреть сообщение
Thanks REPPED!
Welcome bro!
Reply
#7

thanks faisal
Reply
#8

Quote:
Originally Posted by Gamer_007
Посмотреть сообщение
thanks faisal
Np DUDE!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)