/admins to display all online admins
#1

I basically want it to print what admins are currently online, like this:

------------
Admins:
Title - Name1
Title - Name2
Moderators:
Title - Name3
Title - Name4
------------

How would I do this?
I think the names could be found with a loop, but I'm not sure how I'd add the titles.
Currently the pAdmin system is stored as an int ranging from 0 to 5.
I want the titles to be as following:
0 = Player (But it wouldn't get displayed under administrators anyways)
1 = Trial Moderator
2 = Moderator
3 = Administrator
4 = Senior Administrator
5= Server Owner
Reply
#2

I've got it working, however I'd like it to say 'None' if there are no admins/moderators online, how would I do that?

Код HTML:
	if (strcmp("/admins", cmdtext, true, 7) == 0)
	{
        SendClientMessage(playerid, COLOR_WHITE, "Administrators:");
		for (new i = 0; i < MAX_PLAYERS; i++)
		{
	    	if (IsPlayerConnected(i))
	    	{
	        	if (PlayerInfo[i][pAdmin] == 5)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Server owner - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
		        
		        if (PlayerInfo[i][pAdmin] == 4)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Senior Administrator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
		        
          		if (PlayerInfo[i][pAdmin] == 3)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Administrator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
		    }
		}
  		SendClientMessage(playerid, COLOR_WHITE, "Moderators:");
		for (new i = 0; i < MAX_PLAYERS; i++)
		{
	    	if (IsPlayerConnected(i))
	    	{
	        	if (PlayerInfo[i][pAdmin] == 2)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Moderator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }

		        if (PlayerInfo[i][pAdmin] == 1)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Trial Moderator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
			}
		}
		return 1;
	}
Reply
#3

Create a new variable and increase it's number each time an admin is found. If that variable is zero that means no admins were found, therefor you can display that there are no admins online.
Reply
#4

I actually found a solution whilst waiting for a response, haha, but I think I came up with the same thing as you just said? It's working anyway.

Код HTML:
	if (strcmp("/admins", cmdtext, true, 7) == 0)
	{
        SendClientMessage(playerid, COLOR_PURPLEGRAY, "Administrators:");
		new a = 0;
		new b = 0;
		for (new i = 0; i < MAX_PLAYERS; i++)
		{
	    	if (IsPlayerConnected(i))
	    	{
	        	if (PlayerInfo[i][pAdmin] == 5)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Server owner - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
		        
		        if (PlayerInfo[i][pAdmin] == 4)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Senior Administrator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }
		        
          		if (PlayerInfo[i][pAdmin] == 3)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Administrator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
				}
				
				if (PlayerInfo[i][pAdmin] > 3)
				{
				    a++;
		        }
		    }
		}
		if (a < 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "None");
		}
  		SendClientMessage(playerid, COLOR_PURPLEGRAY, "Moderators:");
		for (new i = 0; i < MAX_PLAYERS; i++)
		{
	    	if (IsPlayerConnected(i))
	    	{
	        	if (PlayerInfo[i][pAdmin] == 2)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Moderator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
		        }

		        if (PlayerInfo[i][pAdmin] == 1)
	        	{
		            new string[32+MAX_PLAYER_NAME+1];
		            new adminname[MAX_PLAYER_NAME+1];
		            GetPlayerName(i, adminname, sizeof(adminname));
		            format(string, sizeof(string), "Trial Moderator - %s", adminname);
		            if (Administrator[i] == 1)
		            {
			            SendClientMessage(playerid, COLOR_ORANGE, string);
		            }
		            else
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, string);
		            }
				}

				if (PlayerInfo[i][pAdmin] < 3)
		        {
      				if (PlayerInfo[i][pAdmin] > 0)
					{
				    	b++;
		        	}
				}
			}
		}
		if (b < 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "None");
		}
		return 1;
	}
Reply
#5

plz use zcmd so anyone can help you easily!
Reply
#6

PHP код:
here is Whole CMD
CMD
:admins(playeridparams[])
{
       new 
tot ,szString[256];
       
SendClientMessage(playeridCOLOR_ORANGE"***Administators Online***");
       for(new 
i=0;iMAX_PLAYERS;i++) {
          if (
IsPlayerConnected(i)) {
             if (
Player[i][pAdmin] >= 1) {
                 new 
PlayerName[MAX_PLAYER_NAME];
                 
GetPlayerName(iPlayerNamesizeof(PlayerName));
                
tot++;
                
format(szStringsizeof(szString), "{FF0000}Admin {FF0000}%s [Level: %d] [{375FFF}%s{FF0000}]"PlayerNamePlayer[i][pAdmin], staffrank(i));
                
SendClientMessage(playeridCOLOR_AQUAszString);
             }
          }
       }
       if (
tot == 0) {
           
SendClientMessage(playeridCOLOR_AQUA"Admin Found No Admins Online");
       }
       else {
           
format(szStringsizeof(szString), "There are currently ~~ %d ~~ Admins online.."tot);
           
SendClientMessage(playeridCOLOR_ORANGEszString);
       }
       return 
1;
}
stock staffrank(playerid) {
    new 
szString[256];
    switch(
Player[playerid][pAdmin]) {
        case 
0szString "Not a Staff Member";
        case 
1szString "Trial Admin";
        case 
2szString "Senior Moderator";
         case 
3szString "Lead Admin";
         case 
4szString "Head Admin";
         case 
5szString "Server Owner";
    }
    return 
szString;

Reply
#7

But you can use much simple with this

pawn Код:
CMD:admins( playerid, params[ ] )
{
    vString[ 0 ] = EOS;
    new
        Adm
    ;

    foreach(new i: Player)
    {
        if ( PlayerInfo[ i ][ Level ] > 0 )
        {
            format( vString, sizeof( vString ), "{FFFFFF}%s{00FF00}Admin {FF0000}%s {00FF00}- Level {FF0000}%d\n", vString, GetName( i ), PlayerInfo[ i ][ Level ] );
            Adm++;
        }
    }
    if ( Adm == 0 )
        format( vString, sizeof( vString ), "\n{FF0000}No Administrators online at the moment!" );

    ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_LIST, "{FFFFFF}Online Administrators", vString, "Quit", "" );
    return ( 1 );
}

And GetName stock

stock GetrName( playerid )
{
    new name[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, name, MAX_PLAYER_NAME );
    return name;
}
I hope this will help you!
Reply
#8

Loop through all players then check if he's an admin, if he is then display his name.
Reply
#9

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Loop through all players then check if he's an admin, if he is then display his name.
Not just the name , Level and Name
Reply
#10

I've already got it working everybody Even made a command for administrators to hide themself from /admins

Thanks for the help, though. Never used zcmd so it kinda confuses me, all I use for commands is strcmp and dcmd, depending on the command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)