Create command /admins in dialog
#1

Hi I'm making a command to see the online admins on the server , this is the code

Код:
CMD:admins(){
    new string[256];
    new fstring[64];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(Admin[playerid]>= 0)
        {
            GetPlayerName(i,adminname, sizeof(adminname));
            format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[playerid]);
            strcat(string, fstring, sizeof(string));
        }
    }
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 1;
}

Then to try it in the server gives me so






What I want is when the player put / admins, you show admins who are connected as in the picture below



Thank you for your attention and your help
Reply
#2

Quote:
Originally Posted by Z4firo
Посмотреть сообщение
Hi I'm making a command to see the online admins on the server , this is the code

Код:
CMD:admins(playerid){
    new string[256];
    new fstring[64];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(Admin[playerid]>= 0)
        {
            GetPlayerName(i,adminname, sizeof(adminname));
            format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[playerid]);
            strcat(string, fstring, sizeof(string));
        }
    }
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 1;
}
You are checking Admin[playerid], and you must check if the player connected also
also, you do (Admin[i] >= 0), also non admins will be formatted here is the right code
increase string size a little bit more
PHP код:
CMD:admins(playerid){
    new 
string[300];
    new 
fstring[64];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
Admin[i] > && IsPlayerConnected(i))
        {
            
GetPlayerName(i,adminnamesizeof(adminname));
            
format(fstringsizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n"adminnamei,Admin[i]);
            
strcat(stringfstringsizeof(string));
        }
    }
    
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 
1;

Reply
#3

Keep the first one. The second one is a bit messy.
Reply
#4

Quote:
Originally Posted by Shinja
Посмотреть сообщение
You are checking Admin[playerid], and you must check if the player connected also
also, you do (Admin[i] >= 0), also non admins will be formatted here is the right code
increase string size a little bit more
PHP код:
CMD:admins(playerid){
    new 
string[300];
    new 
fstring[64];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
Admin[i] > && IsPlayerConnected(i))
        {
            
GetPlayerName(i,adminnamesizeof(adminname));
            
format(fstringsizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n"adminnamei,Admin[i]);
            
strcat(stringfstringsizeof(string));
        }
    }
    
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 
1;

I put the code but when you try it on the server I get: unknown command
Reply
#5

Strange.. Try this
PHP код:
CMD:admins(){
    new 
string[300], fstring[64], adminname[25];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
Admin[i] > && IsPlayerConnected(i))
        {
            
GetPlayerName(i,adminnamesizeof(adminname));
            
format(fstringsizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n"adminnamei,Admin[i]);
            
strcat(stringfstringsizeof(string));
        }
    }
    
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 
1;

Reply
#6

Hello.

This is the right code:

PHP код:

CMD
:admins(playeridparams[])
{
    new 
string[500], 0aname[MAX_PLAYER_NAME];
    
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(!
IsPlayerConnected(i)) continue;
        if(!
Admin[i]) continue;
        
        
GetPlayerName(ianamesizeof(aname));
        
format(stringsizeof(string), "%s%s (%d) - {FF0000}Level: %d{FFFFFF}\n"stringanameiAdmin[i]);
        
t++;
        
ShowPlayerDialog(playerid1DIALOG_STYLE_MSGBOX"Online admins"string"Close"""); 
    }
    if(!
t) return SendClientMessage(playerid, -1"There are no admins.");
    
    return 
1;

Reply
#7

Quote:
Originally Posted by Shinja
Посмотреть сообщение
Strange.. Try this
PHP код:
CMD:admins(){
    new 
string[300], fstring[64], adminname[25];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
Admin[i] > && IsPlayerConnected(i))
        {
            
GetPlayerName(i,adminnamesizeof(adminname));
            
format(fstringsizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n"adminnamei,Admin[i]);
            
strcat(stringfstringsizeof(string));
        }
    }
    
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
    return 
1;

How is it strange?
Код:
CMD:admins(){
Reply
#8

Quote:
Originally Posted by WhiteGhost
Посмотреть сообщение
How is it strange?
Код:
CMD:admins(){
Strange because it must work dude
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)