/admins dialog help
#1

Why my admins dialog will only show one admin

PHP код:
dcmd_admins(playerid,params[])
{
    
#pragma unused params
    
new count=0,string[128],rank[128];
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && GetInfo(i,"AdminLevel")>= 1)
        {
            
format(string128"{FF02A7}%s              {ffffff}Level: %d"AdminName(i),GetInfo(i,"AdminLevel"));
            
ShowPlayerDialog(playerid5559DIALOG_STYLE_MSGBOX"Online administrator"string"Close""");
            
count++;
        }
    }
    if (
count == 0SendClientMessage(playerid,LIGHTBLUE,"{FF02A7}[Admin]:{ffffff}There Are no Admins Online");
    return 
1;

Reply
#2

It shows only one person because you are showing the dialog after you find the first person. You need to show it after getting all the players.
Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new count=0,string[128],rank[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetInfo(i,"AdminLevel")>= 1)
        {
            format(string, 128, "{FF02A7}%s              {ffffff}Level: %d", AdminName(i),GetInfo(i,"AdminLevel"));
            count++;
        }
    }
    if(count) ShowPlayerDialog(playerid, 5559, DIALOG_STYLE_MSGBOX, "Online administrator", string, "Close", "");
    if (count == 0) SendClientMessage(playerid,LIGHTBLUE,"{FF02A7}[Admin]:{ffffff}There Are no Admins Online");
    return 1;
}
Btw, this will again not work because you need to use fomat and strcat to add all players to the string.
Reply
#3

Not works! The same problems.
Reply
#4

pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new count=0,string[128],rank[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetInfo(i,"AdminLevel")>= 1)
        {
            format(string, 128, "{FF02A7}%s              {ffffff}Level: %d", AdminName(i),GetInfo(i,"AdminLevel"));
            count++;
        }
        ShowPlayerDialog(playerid, 5559, DIALOG_STYLE_MSGBOX, "Online administrator", string, "Close", "");  
    }
    if (count == 0) SendClientMessage(playerid,LIGHTBLUE,"{FF02A7}[Admin]:{ffffff}There Are no Admins Online");
    return 1;
}
Reply
#5

This should work..
pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new count=0,string[1028],rank[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetInfo(i,"AdminLevel")>= 1)
        {
            format(string, 1028, "%s{FF02A7}%s              {ffffff}Level: %d", string, AdminName(i),GetInfo(i,"AdminLevel"));
            count++;
        }
    }
    if (count == 0) SendClientMessage(playerid,LIGHTBLUE,"{FF02A7}[Admin]:{ffffff}There Are no Admins Online");
    else if(count != 0) ShowPlayerDialog(playerid, 5559, DIALOG_STYLE_MSGBOX, "Online administrator", string, "Close", "");
    return 1;
}
Reply
#6

Like I said, you need to use strcat and yet people are posting codes with only format *sigh*
pawn Код:
dcmd_admins(playerid,params[])
{
    new count=0,string[128],rank[128], first, string2[40];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetInfo(i,"AdminLevel")>= 1)
        {
            if(first)
                format(string, sizeof(string), "{FF02A7}%s (Lvl. %d)", AdminName(i),GetInfo(i,"AdminLevel"));
            else
            {
                format(string2, sizeof(string2), "\n{FF02A7}%s (Lvl. %d)", AdminName(i),GetInfo(i,"AdminLevel"));
                strcat(string, string2, sizeof(string));
            }
            count++;
        }
    }
    if(count) ShowPlayerDialog(playerid, 5559, DIALOG_STYLE_MSGBOX, "Online administrator", string, "Close", "");
    if (count == 0) SendClientMessage(playerid,LIGHTBLUE,"{FF02A7}[Admin]:{ffffff}There Are no Admins Online");
    return 1;
}
Try that code, it's not tested.
Reply
#7

pawn Код:
if(count) ShowPlayerDialog(playerid, 5559, DIALOG_STYLE_MSGBOX, "Online administrator", string, "Close", "");
If the count is 1, then show the dialog? Seriously.
strcat isn't really important over there, you can just format the string and show the show if the count is > 0.

EDIT: Lol, you even edited your old code (which was incorrect)
Reply
#8

Thank it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)