Dialog Strings
#1

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?
Reply
#2

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.
Reply
#3

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?
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)