SA-MP Forums Archive
Dialog Problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dialog Problem (/showthread.php?tid=278722)



Please help - Hoss - 23.08.2011

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


Re: Dialog Problem - Jeffry - 23.08.2011

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


Re: Dialog Problem - Hiddos - 23.08.2011

This might work: http://pastebin.com/vR8D1868


Re: Dialog Problem - Jeffry - 23.08.2011

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


AW: Dialog Problem - Nero_3D - 23.08.2011

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



Re: Dialog Problem - PrawkC - 23.08.2011

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.


Re: Dialog Problem - Hoss - 24.08.2011

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


AW: Re: Dialog Problem - Nero_3D - 24.08.2011

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 ?


Re: Dialog Problem - Intoxicated - 24.08.2011

EDIT: Oops.. wrong topic


Re: Dialog Problem - iPLEOMAX - 24.08.2011

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