SA-MP Forums Archive
Create command /admins in dialog - 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: Create command /admins in dialog (/showthread.php?tid=614903)



Create command /admins in dialog - Z4firo - 14.08.2016

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


Re: Create command /admins in dialog - Shinja - 14.08.2016

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;




Re: Create command /admins in dialog - Fantje - 14.08.2016

Keep the first one. The second one is a bit messy.


Re: Create command /admins in dialog - Z4firo - 14.08.2016

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


Re: Create command /admins in dialog - Shinja - 14.08.2016

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;




Re: Create command /admins in dialog - DarkLouis - 14.08.2016

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;




Re: Create command /admins in dialog - WhiteGhost - 14.08.2016

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(){



Re: Create command /admins in dialog - Shinja - 15.08.2016

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