SA-MP Forums Archive
Dialog Strings - 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: Dialog Strings (/showthread.php?tid=554539)



Dialog Strings - BornHuman - 04.01.2015

I have a max amount of groups set to 20, starting from 0 to 19. I want to loop through them and make a dialog for them in the blow command:

pawn Code:
command(editgroup, playerid, params[])
{
    if(Player[playerid][AdminLevel] >= 1337)
    {
        new string[128];
        for(new i = 0; i < MAX_GROUPS; i++)
        {
            format(string, sizeof(string), "Groups/Group_%d.ini", i);
            if(fexist(string))
            {
                format(string, sizeof(string), "%d.) %s\n.", i, Groups[i][GroupName]);
                ShowPlayerDialog(playerid, 9001, DIALOG_STYLE_LIST, "Groups | Edit Group", string, "Select", "Cancel");
            }
        }
    }
    return 1;
}
However, when I execute /editgroup in game, only id 20 shows up, no others. Why?


Re: Dialog Strings - SickAttack - 04.01.2015

Use strcat instead of format. You are formating the string over and over untill it reaches the last group instead of storing each one of them in a string then showing it later on.


Re: Dialog Strings - BornHuman - 04.01.2015

Quote:
Originally Posted by SickAttack
View Post
Use strcat instead of format. You are formating the string over and over untill it reaches the last group instead of storing each one of them in a string then showing it later on.
Mind giving me an example?


Re: Dialog Strings - SickAttack - 04.01.2015

pawn Code:
new content[500], string[6];
for(new i = 0; i < 100; i ++)
{
    format(string, sizeof(string), "%03d\n", i);
    strcat(content, string);
}

ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Numbers", content, "Close");
Sent from mobile.