SA-MP Forums Archive
/admins shows all players online - 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: /admins shows all players online (/showthread.php?tid=510629)



/admins shows all players online - AndySedeyn - 01.05.2014

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


Re: /admins shows all players online - PrivatioBoni - 01.05.2014

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.


Re: /admins shows all players online - Konstantinos - 01.05.2014

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.


Re: /admins shows all players online - XK - 01.05.2014

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



Re: /admins shows all players online - AndySedeyn - 01.05.2014

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