SA-MP Forums Archive
How to make a /afklist command? - 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)
+--- Thread: How to make a /afklist command? (/showthread.php?tid=303453)



How to make a /afklist command? - SomebodyAndMe - 13.12.2011

Does anyone know how to make this, I have already a variable setted for my normal /afk and /back but now I want people to see who is /afk.

Variable at top of script:
pawn Код:
new IsAFK[MAX_PLAYERS];
It must be like in
pawn Код:
COMMAND:afklist(playerid,params[])
new Msg[128], Afkname[24];
{
   
    format(Msg, 128, "{FF6600}s%", Afkname[24]); // the guy who is AFK.
    SendClientMessage(playerid, 0xFFFFFFFF, "People who are AFK:")
    SendClientMessage(playerid, 0xFFFFFFFF, Msg)
}
Someone could help?


Re: How to make a /afklist command? - Ballu Miaa - 13.12.2011

Код:
COMMAND:afklist(playerid,params[])
new Msg[128], Afkname[24];
{
    
    format(Msg, 128, "{FF6600}%s is now AFK", Afkname[24]); // the guy who is AFK.
    SendClientMessage(playerid, 0xFFFFFFFF, Msg)
}
This can be the correct code for you according to your code!


Re: How to make a /afklist command? - eDz0r - 13.12.2011

Something like this...
pawn Код:
command(afklist, playerid, params)
{
new pString[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];

for(new pID = 0; pID < MAX_PLAYERS; pID ++)
{
if(IsPlayerConnected(pID)
{
if(IsPlayerAFK[pID] == 1)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Players on AFK");
GetPlayerName(playerid, pName, sizeof(pName));
format(pString, sizeof(pString), "%s" pName);
SendClientMessage(playerid, 0xFFFFFFFF, pString);
}
}
}
return 1;
}



Re: How to make a /afklist command? - Rob_Maate - 13.12.2011

untested, but I see no reason this shoudn't work

pawn Код:
CMD:afklist(playerid)
{
    new pString[MAX_PLAYER_NAME + 2];
    new pName[MAX_PLAYER_NAME];
    SendClientMessage(playerid, 0xFFFF00AA, "|_____AFK Players_____|");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)
        {
            if(IsAFK[i] == 1)
            {
                GetPlayerName(i, pName, sizeof(pName));
                format(pString, sizeof(pString), "> %s" pName);
                SendClientMessage(playerid, 0xFFFFFFAA, pString);
            }
        }
    }
    return 1;
}



Re: How to make a /afklist command? - Ballu Miaa - 14.12.2011

Quote:
Originally Posted by Rob_Maate
Посмотреть сообщение
untested, but I see no reason this shoudn't work

pawn Код:
CMD:afklist(playerid)
{
    new pString[MAX_PLAYER_NAME + 2];
    new pName[MAX_PLAYER_NAME];
    SendClientMessage(playerid, 0xFFFF00AA, "|_____AFK Players_____|");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)
        {
            if(IsAFK[i] == 1)
            {
                GetPlayerName(i, pName, sizeof(pName));
                format(pString, sizeof(pString), "> %s" pName);
                SendClientMessage(playerid, 0xFFFFFFAA, pString);
            }
        }
    }
    return 1;
}
Yeah it will according to his functions. I hope so!


Re: How to make a /afklist command? - SomebodyAndMe - 14.12.2011

Well in his script were only errors, like he forgot an ) at the end and some other stuff.

Well it's fixed now, thanks for helping me out. BUt remember i'm not a copy-paste-aholic.