Online admins in dialog
#1

Hello, how to make command that display all online admins in dialog style: DIALOG_STYLE_MSGBOX
I want every admin to be on new line.
Reply
#2

Код:
CMD:admins(playerid,params[])
{
    new A_String[ 150 ], count = 0, AdminPos[ 30 ];
	foreach(Player, i)
 	{
  		if( Bit4_Get( AdminLevel, i ) >= 1 || IsPlayerAdmin( i ) )
    	{
     		if(      Bit4_Get( AdminLevel, i ) == 1 ) AdminPos = ""#RED"Newbie Admin";
       		else if( Bit4_Get( AdminLevel, i ) == 2 ) AdminPos = ""#RED"Moderator";
         	else if( Bit4_Get( AdminLevel, i ) == 3 ) AdminPos = ""#RED"Administrator";
          	else if( Bit4_Get( AdminLevel, i ) == 4 ) AdminPos = ""#RED"Head Administrator";
           	else if( Bit4_Get( AdminLevel, i ) == 5 ) AdminPos = ""#RED"Server Owner";
           	else if( IsPlayerAdmin(        i )      ) AdminPos = ""#RED"RCON Admin";

            format( A_String, sizeof( A_String ),"%s"#GREEN"%s[ID:%d] "#YELLOW"- "#BLUE"%s \n", A_String, GetName( i ), i, AdminPos );
            ShowPlayerDialog( i, A_D_ON , 0, ""#WHITE"Online Admins", A_String, "OK", "" );
            count++;
          }
 		else if( count == 0 )
        {
            ShowPlayerDialog( i, A_D_ON, 0, "Admins Online", ""WHITE"No Admins Online!", "OK", "" );
        }
	}
    return 1;
}
Change admin variables to make compatible with your script
Reply
#3

Try making a for loop and checking for Admins and then use format function to join all adminsand make a text and display it.
Example:
Код:
admins[][]
new a;
new sting[];
for(new i;i == MAX_PLAYERS;i++)
{
    if(IsPlayerAdmin(playerid))
   {
       GetPlayerName(playerid,admins[a]);
       a++;
   }
}
for(new b == 01;b == a;b++)
{
     format(string,sizeof(string),"%s %s",string,admins[a]);
}
ShowPlayerDialog(......); //Just print it.
I have not tested it but it may work.
Reply
#4

Result is Unknown Command.
Where's wrong ?

pawn Код:
if(strcmp(cmd, "/allhouses",true)==0)
{
    new info[2000];
    for(new i = 0; i < 30; i++)
    {
        if(HouseInfo[i][hOwned] == 0)
        {
            format(string,sizeof(string),"{00FF00}House ID %d: The House Is Free\n",i);
        }
        else
        {
            format(string,sizeof(string),"{FF8000}House ID %d: Owned by: %s\n",i,HouseInfo[i][hOwner]);
        }
        strcat(info, string, sizeof(info));
        ShowPlayerDialog(playerid,17,DIALOG_STYLE_MSGBOX,"{0080FF}ALL HOUSES:",info,"Other","Close");
    }
    return 1;
}
Reply
#5

pawn Код:
if(strcmp(cmd, "/allhouses",true)==0)
{
    new info[2000];
               info[0] = '\0';
    for(new i = 0; i < 30; i++)
    {
        if(HouseInfo[i][hOwned] == 0)
        {
            format(string,sizeof(string),"{00FF00}House ID %d: The House Is Free\n",i);
        }
        else
        {
            format(string,sizeof(string),"{FF8000}House ID %d: Owned by: %s\n",i,HouseInfo[i][hOwner]);
        }
        strcat(info, string, sizeof(info));
        ShowPlayerDialog(playerid,17,DIALOG_STYLE_MSGBOX,"{0080FF}ALL HOUSES:",info,"Other","Close");
    }
    return 1;
}
Edit: I see you are formatting a string, but do you have it declared?
Reply
#6

Universal Yes, I do.
I added smo things in command and I have another problem. The dialog displayed with the text, but when get to owned house the line not displayed and stopped there. (sorry for my bad english)
Where's wrong ?

pawn Код:
if(strcmp(cmd, "/allhouses",true)==0)
{
    if (PlayerInfo[playerid][pAdminLevel] >= 4)
    {
        new strings[256];
        new info[2000];
        info[0] = '\0';
        for(new i = 0; i < 30; i++)
        {
            if(HouseInfo[i][hOwned] == 0)
            {
                format(string,sizeof(string),"{00FF00}House ID %d: The House Is Free\n",i);
            }
            else
            {
                format(strings, sizeof(strings), "%s.ini",HouseInfo[i][hOwner]);
                if(dini_Exists(strings))
                {
                    new s = dini_Int(strings, "Second");
                    new m = dini_Int(strings, "Minute");
                    new h = dini_Int(strings, "Hour");
                    new d = dini_Int(strings, "Day");
                    new mo = dini_Int(strings, "Month");
                    new y = dini_Int(strings, "Year");
                    format(string,sizeof(string),"{FF8000}House ID %d: Owner: %s, Last login: %s%d.%s%d.%d and %s%d:%s%d:%s%d PM!\n",i,HouseInfo[i][hOwner],(d < 10) ? ("0") : (""), d, (mo < 10) ? ("0") : (""), mo, y, (h < 10) ? ("0") : (""), h, (m < 10) ? ("0") : (""), m, (s < 10) ? ("0") : (""), s);
                }
            }
            strcat(info, string, sizeof(info));
            ShowPlayerDialog(playerid,17,DIALOG_STYLE_MSGBOX,"{0080FF}ALL HOUSES:",info,"Other","Close");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "You're not admin!");
    }
    return 1;
}
Reply
#7

If you want to acheive the integer with leading zeros, use %02d instead of the ternary operator. Example:

pawn Код:
format(string, sizeof(string), "Time %02d:%02d", hour, minute);
Reply
#8

Alright, I made this, but I still have the problem. Any other ideas ?
Reply
#9

BUMP!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)