/admins shows only 1 admin
#1

Hello community,

today I have a problem with my /admins command which is supposed to show all avaliable administrators online! The problem is, that it shows only one admin, and that is fore example me.

I was admin, i give admin levels to other players and the only one on the server visible in the admin list was I.

Here is my code:

PHP код:
CMD:admins(playeridparams [] )
{
    new 
online=0level[30], string[256];
    for(new 
GetMaxPlayers(), iJi++ )
    {
        if(
IsPlayerConnected(i) && PlayerInfo[i][pAdmin])
        {
            
online ++;
            switch(
PlayerInfo ][ pAdmin ] )
             {
                case 
1level "Administrбtor-kandidбt";
                case 
2level "Administrбtor";
                case 
3level "Vedoucн Administrбtor";
                case 
4level "Hlavnн Administrбtor";
                case 
5level "Sprбvce serveru";
            }
              
format(stringsizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r"GetName(i), leveli);
        }
    }
    if(!
online)
    {
         
ShowPlayerDialog(playeridDIALOG_NOADMINSDIALOG_STYLE_MSGBOX"Online administrбtori""Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor""Ok""");
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_ADMINSDIALOG_STYLE_MSGBOX"Online administrбtoři"string"Ok""");
    }
    return 
1;

For any solutionable help I would be happy for and appreciate it so much, that i would add an reputation point to the person, that solves my problem.

THank you very much.
Reply
#2

PHP код:
CMD:admins(playeridparams [] ) 

    new 
online=0level[30], string[256]; 
    for(new 
0MAX_PLAYERSi++)
    { 
        if(
IsPlayerConnected(i) && PlayerInfo[i][pAdmin]) 
        { 
            
online ++; 
            switch(
PlayerInfo ][ pAdmin ] ) 
             { 
                case 
1level "Administrбtor-kandidбt"
                case 
2level "Administrбtor"
                case 
3level "Vedoucн Administrбtor"
                case 
4level "Hlavnн Administrбtor"
                case 
5level "Sprбvce serveru"
            } 
              
format(stringsizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r"GetName(i), leveli); 
        } 
    } 
    if(!
online
    { 
         
ShowPlayerDialog(playeridDIALOG_NOADMINSDIALOG_STYLE_MSGBOX"Online administrбtori""Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor""Ok"""); 
    } 
    else 
    { 
        
ShowPlayerDialog(playeridDIALOG_ADMINSDIALOG_STYLE_MSGBOX"Online administrбtoři"string"Ok"""); 
    } 
    return 
1

Changed: for(new J = GetMaxPlayers(), i; i < J; i++ )
To: for(new i = 0; i < MAX_PLAYERS; i++)

Try this.
Reply
#3

Quote:
Originally Posted by willbedie
Посмотреть сообщение
PHP код:
CMD:admins(playeridparams [] ) 

    new 
online=0level[30], string[256]; 
    for(new 
0MAX_PLAYERSi++)
    { 
        if(
IsPlayerConnected(i) && PlayerInfo[i][pAdmin]) 
        { 
            
online ++; 
            switch(
PlayerInfo ][ pAdmin ] ) 
             { 
                case 
1level "Administrбtor-kandidбt"
                case 
2level "Administrбtor"
                case 
3level "Vedoucн Administrбtor"
                case 
4level "Hlavnн Administrбtor"
                case 
5level "Sprбvce serveru"
            } 
              
format(stringsizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r"GetName(i), leveli); 
        } 
    } 
    if(!
online
    { 
         
ShowPlayerDialog(playeridDIALOG_NOADMINSDIALOG_STYLE_MSGBOX"Online administrбtori""Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor""Ok"""); 
    } 
    else 
    { 
        
ShowPlayerDialog(playeridDIALOG_ADMINSDIALOG_STYLE_MSGBOX"Online administrбtoři"string"Ok"""); 
    } 
    return 
1

Changed: for(new J = GetMaxPlayers(), i; i < J; i++ )
To: for(new i = 0; i < MAX_PLAYERS; i++)

Try this.
Actually a correct fast loop would look like this without using foreach:
PHP код:
for(new iGetPlayerPoolSize(); <= ji++) 
Reply
#4

The loop isn't the problem. His original loop was fine.

PHP код:
format(stringsizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r"GetName(i), leveli); 
You aren't formatting it correctly. e.g:
Код:
format(string, sizeof(string), "%s%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n",  string, GetName(i), level, i);
Check the highlighted additions.
Reply
#5

Yeah i never really said it was, was just pointing out there's a better way to do it instead of using max_players to get a more proper fast result. But good catch that is indeed the problem.
Reply
#6

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
The loop isn't the problem. His original loop was fine.

PHP код:
format(stringsizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r"GetName(i), leveli); 
You aren't formatting it correctly. e.g:
Код:
format(string, sizeof(string), "%s%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n",  string, GetName(i), level, i);
Check the highlighted additions.
Didn't even notice that lol
Reply
#7

Hell no, I can not beleive i did not notice this.

There obviously needs to be string in that format too, since in case of another admin online, we need to write the same format again, on the other line. Thanks!
Reply
#8

CMD:admins(playerid, params [] )
{
new on‌line=0, level[30], string[100], strings[500];
for(new J = GetMaxPlayers(), i; i < J; i++ )
{
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin])
{
online ++;
switch(PlayerInfo [ i ][ pAdmin ] )
{
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s {FF0000}%s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r", GetName(i), level, i);
strcat(strings, string);
}
}
if(!online)
{
ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtori", "Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor", "Ok", "");
}
else
{
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", strings, "Ok", "");
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)