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



/admins dialog help - JawsPlus - 08.11.2014

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;




Re: /admins dialog help - dominik523 - 08.11.2014

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.


Re: /admins dialog help - JawsPlus - 08.11.2014

Not works! The same problems.


Re: /admins dialog help - Diverse - 08.11.2014

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;
}



Re: /admins dialog help - biker122 - 08.11.2014

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;
}



Re: /admins dialog help - dominik523 - 08.11.2014

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.


Re: /admins dialog help - biker122 - 08.11.2014

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)


Re: /admins dialog help - JawsPlus - 08.11.2014

Thank it works.