Dialog Problem
#1

Hello
I want to make /admins with dialogs
But i got some problems,with doing it
This is original /admins cmd wiht no dialogs
pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[128],amt;
    string = "Admins: ";
    if(IsPlayerAdmin(playerid) || Variables[playerid][Level] > 12)
    {
        foreach(Player,i)
        {
            if(Variables[i][Level] < 12 && Variables[i][Level] > 0)
            {
                format(string,128,"%s  %s(%d)",string,RealName[i],Variables[i][Level]);
                amt++;
            }
        }
    }
    else
    {
        foreach(Player,i)
        {
            if(Variables[i][Level] < 12 && Variables[i][Level] > 0)
            {
                format(string,128,"%s  %s",string,RealName[i]);
                amt++;
            }
        }
    }
    if(amt > 0)return SendClientMessage(playerid,MAIN_COLOR_2,string);
    else return SendClientMessage(playerid,MAIN_COLOR_2,"No admins online.");
}
and i tried to make it with dialogs,but when i am typing /admins IG i am gettin only 1 admin line
pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Variables[i][Level] >0 && Variables[i][Level] < 10)
        {
            format(string, sizeof(string), "{FF0000}ADMINISTRATOR: %s ID[%d]{15D4ED}[Level %d]\n", RealName[i],playerid, Variables[i][Level]);
            ShowPlayerDialog(playerid, 5591, 0, "{1B1BE0}Online Admins:", string, "Done", "");
        }
    }
    return 1;
}
Please help me
Reply
#2

pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[400], admins;
    for(new i = 0; i < MAX_PLAYERS; i++) if(Variables[i][Level] >0 && Variables[i][Level] < 10) admins++;
    if(admins > 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(Variables[i][Level] >0 && Variables[i][Level] < 10)
            {
                format(string, sizeof(string), "%s{FF0000}ADMINISTRATOR: %s ID[%d]{15D4ED}[Level %d]\n",string, RealName[i],playerid, Variables[i][Level]);
                ShowPlayerDialog(playerid, 5591, 0, "{1B1BE0}Online Admins:", string, "Done", "");
            }
        }
    }
    else ShowPlayerDialog(playerid, 5591, 0, "{1B1BE0}Online Admins:", "There are no Administrators online.", "Done", "");
    return 1;
}
Should work then.

Jeffry
Reply
#3

This might work: http://pastebin.com/vR8D1868
Reply
#4

Oh, good one Hiddos, didn't think of that way.
Reply
#5

If I am not mistaken, than Hiddos code would always show "No admins online!" and the online admins if there are some

pawn Code:
dcmd_admins(playerid, unused[]) {
    #pragma unused unused
    new
        i = 0,
        string[400];
    for( ; i != MAX_PLAYERS; ++i) { // foreach ?
        if(0 < Variables[i][Level] < 10) {
            format(string, sizeof string, "%s{FF0000}ADMINISTRATOR: %s ID[%d]{15D4ED}[Level %d]\n", string, RealName[i], i, Variables[i][Level]);
        }
    }
    if(string[0] == EOS) {
        string = "No admins online.";
    }
    ShowPlayerDialog(playerid, 5591, DIALOG_STYLE_MSGBOX, "{1B1BE0}Online Admins:", string, "Done", "");
    return true;
}
Reply
#6

pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[256], result[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Variables[i][Level] >0 && Variables[i][Level] < 10)
        {
            format(string, sizeof(string), "{FF0000}ADMINISTRATOR: %s ID[%d]{15D4ED}[Level %d]\n", RealName[i],playerid, Variables[i][Level]);
            strcat(result, string, sizeof(result));      
        }
    }
    ShowPlayerDialog(playerid, 5591, 0, "{1B1BE0}Online Admins:", result, "Done", "")
    return 1;
}
Pretty sure this will work.
Reply
#7

Quote:
Originally Posted by PrawkC
View Post
pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[256], result[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Variables[i][Level] >0 && Variables[i][Level] < 10)
        {
            format(string, sizeof(string), "{FF0000}ADMINISTRATOR: %s ID[%d]{15D4ED}[Level %d]\n", RealName[i],playerid, Variables[i][Level]);
            strcat(result, string, sizeof(result));      
        }
    }
    ShowPlayerDialog(playerid, 5591, 0, "{1B1BE0}Online Admins:", result, "Done", "")
    return 1;
}
Pretty sure this will work.
Thanks
but can anyone help me to make 2 admin lines,cuz when here are 2+ admins in admin list is only 1 admin
Help me please
Reply
#8

Quote:
Originally Posted by [MD]Gangster
View Post
Thanks
but can anyone help me to make 2 admin lines,cuz when here are 2+ admins in admin list is only 1 admin
Help me please
He used result instead of string in ShowPlayerDialog, just change it by yourself

Also did you tried Jeffry's, Hiddos's or mine ?
Reply
#9

EDIT: Oops.. wrong topic
Reply
#10

Untested:

pawn Code:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new string[MAX_PLAYER_NAME+8*15], stringb[MAX_PLAYER_NAME+8], amt;
   
    if(IsPlayerAdmin(playerid) || Variables[playerid][Level] > 12)
    {
        foreach(Player, i)
        {
            if(Variables[i][Level] < 12 && Variables[i][Level] > 0)
            {
                format(stringb, sizeof stringb,"%s(%d)", RealName[i], Variables[i][Level] );
                strcat(string, stringb, sizeof string);
                amt++;
            }
        }
    }
    else
    {
        foreach(Player,i)
        {
            if(Variables[i][Level] < 12 && Variables[i][Level] > 0)
            {
                format(stringb,sizeof stringb,"%s", RealName[i] );
                strcat(string, stringb, sizeof string);
                amt++;
            }
        }
    }
    if(amt == 0) return SendClientMessage( playerid, MAIN_COLOR_2, "No admins are online.");
    else return ShowPlayerDialog(playerid, 4557, DIALOG_STYLE_LIST, "Current Online Admins:", string, "OK", "Close");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)