/admins shows all players online
#1

Hello folks
I'm scripting a command for players to show online admins.

Concept:
If a player does /admins it shows a list of all the admins online and whether they're on Admin duty or not.

Problem:
If another player logs in to the server he is also visible in the list.

pawn Код:
CMD:admins(playerid, params[])
{
    if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
    if(IsPlayerConnected(playerid))
    {
        SCM(playerid, COLOR_LBLUE, " ");
        SCM(playerid, COLOR_LBLUE, "----------| Online Admins |----------");
        for(new i = 0; i < MAX_ADMINS; i++)
        {
            if(IsPlayerConnected(i))
            {
                new aname[48], atitle[48], string[128];
                if(PlayerInfo[i][pAdmin] == 5) { atitle = "Lead Administrator"; }
                if(PlayerInfo[i][pAdmin] == 4) { atitle = "Senior Administrator"; }
                if(PlayerInfo[i][pAdmin] == 3) { atitle = "Administrator"; }
                if(PlayerInfo[i][pAdmin] == 2) { atitle = "Junior Administrator"; }
                if(PlayerInfo[i][pAdmin] == 1) { atitle = "Helper"; }
                GetPlayerName(i, aname, sizeof(aname));
                if(!AdminDuty[i])
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);
                }
                else
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);
                }
                continue;
            }
        }
    }
    return 1;
}
Help is much appreciated!

Sincerely,
Bible
Reply
#2

You need to check if the person is actually an admin or not, in the loop. Also, checking if the command executor is online is quite pointless as they have to be online to type the command.
Reply
#3

You should check if the player's admin level is not 0 because it will display a non-admin as admin not on duty and with empty/null rank.
Reply
#4

make like:
pawn Код:
if(PlayerInfo[i][pAdmin] > 0)
{
     //send the message
}
Reply
#5

Thanks all of you, I added this:
pawn Код:
if(PlayerInfo[i][pAdmin] > 0)
{
}
+repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)