/admins problem
#1

I use this command but when is there are 2 or more admins online it only write 1 player

PHP код:
dcmd_admins(playerid,params[])
{
    
#pragma unused params
    
new count 0;
     new 
string[128],name[50];
      new 
name1[MAX_PLAYER_NAME];
    for(new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(i,name1,MAX_PLAYER_NAME);
            if(
AdminLevel[i] > 0)
            {
                      if(
AdminLevel[i] == 1)
                    {
name "{FFFF00}Server Moderator {FFFFFF}(Level 1)";}
                     if(
AdminLevel[i] ==2)
                    {
name "{0000BB}Global Moderator {FFFFFF}(Level 2)";}
                       if(
AdminLevel[i] ==3)
                       {
name "{ADFF2F}Administrator {FFFFFF}(Level 3)";}
                       if(
AdminLevel[i] ==4)
                       {
name "{ADFF2F}Lead Adminstrator {FFFFFF}(Level 4)";}
                       if(
AdminLevel[i] ==5)
                       {
name "{FF0000}Owner {FFFFFF}(Level 5)";}
                    
format(string128"\"%s\" {%s}"name1,name);
                    
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"ADMINS ONLINE",string,"Ok","");
                    
count++;
              }
        }
    }
    if (
count == 0)
    
SendClientMessage(playerid,COLOR_ADMIN,"There are no admins Online at the moment");
    return 
1;

Reply
#2

You have to use the previous "string" (I improved it a little):
pawn Код:
dcmd_admins( playerid, params[ ] )
{
    #pragma unused params
    new count = 0, string[ 1024 ], name[ 50 ], name1[ MAX_PLAYER_NAME ];
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if( IsPlayerConnected( i ) )
        {
            GetPlayerName( i, name1, MAX_PLAYER_NAME );
            if( AdminLevel[ i ] > 0 )
            {
                switch( AdminLevel[ i ] )
                {
                    case 1: name = "{FFFF00}Server Moderator {FFFFFF}(Level 1)";
                    case 2: name = "{0000BB}Global Moderator {FFFFFF}(Level 2)";
                    case 3: name = "{ADFF2F}Administrator {FFFFFF}(Level 3)";
                    case 4: name = "{ADFF2F}Lead Adminstrator {FFFFFF}(Level 4)";
                    case 5: name = "{FF0000}Owner {FFFFFF}(Level 5)";
                }

                format( string, 1024, "%s\"%s\" {%s}\n", string, name1, name );
                ShowPlayerDialog( playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "ADMINS ONLINE", string, "Ok", "" );
                count ++;
            }
        }
    }

    if( count == 0 )
        SendClientMessage( playerid, COLOR_ADMIN,"There are no admins Online at the moment" );

    return 1;
}
Also, use foreach in your loops, it's faster.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)