How to make my system skip AFK players? So it doesn't put them in game.
#1

I'm trying to make it so if a player is in the lobby and is afk, (paused) my system will bypass them and only teleport non-paused players into the round.

Here's some relevant code.

pawn Код:
CMD:ready(playerid, params[])
{
    if(IsPlayerReady[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You're already ready.");
    }
    if(GameProgress == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when a game is in progress.");
    }
    if(intro[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when in the introduction.");
    }
    IsPlayerReady[playerid] = 1;
    LobbyCount++;
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    format(string,sizeof(string), "%s is ready to enter the Hunger Games Tournament.",name);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
Reply
#2

Do you have a system that checks to see if a player is AFK yet or do you need this as well?

SA-MP has not integrated the pause-check they use for the gamer-tag icon into code... so one has to be created instead.
Reply
#3

Could you recommend a include for me? Thank you.
Reply
#4

Check this

then it would work smth like this :P

pawn Код:
CMD:ready(playerid, params[])
{
    if(IsPlayerReady[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You're already ready.");
    }
    if(GameProgress == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when a game is in progress.");
    }
    if(intro[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when in the introduction.");
    }
    if(!IsPlayerPause(playerid))
    {
        IsPlayerReady[playerid] = 1;
        LobbyCount++;
    }
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    format(string,sizeof(string), "%s is ready to enter the Hunger Games Tournament.",name);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
I added the ! on the IsPlayerPause to check that the player isn't paused

Test it to see if it works
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=490436

Download it, rename the include to "callbacks.inc" or w.e you want it
Then #include it

And "OnPlayerPause", add a variable which will set the player on pausing, and on "OnPlayerResume", it will disable it
For an example:

pawn Код:
public OnPlayerPause(playerid)
{
    AFK{ playerid } = true;
    return 1;
}

public OnPlayerResume(playerid, time)
{
    AFK{ playerid } = false;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)