3D array into a dialog message
#1

Hello,

I'm trying to insert a three-dimensional array into a dialog box. The code I have just outputs the standard error message whenever I try to type the command in-game. Not getting any compiler errors.

pawn Code:
CMD:teams(playerid, params[])
{
    new arenas[12][2][128] =
    {
        {"Dust 2", "Teaming permitted"},
        {"Jefferson Motel", "Teaming permitted"},
        {"Liberty City", "Teaming forbidden"},
        {"LVPD", "Teaming forbidden"},
        {"Madd Dogg's Mansion", "Teaming permitted"},
        {"Meat Factory", "Teaming forbidden"},
        {"Pleasure Domes", "Teaming forbidden"},
        {"RC Battle Ground", "Teaming permitted"},
        {"Tennis Court", "Teaming forbidden"},
        {"The Farm", "Teaming forbidden"},
        {"The Sewers", "Teaming permitted"},
        {"Western Town", "Teaming permitted"}
    };

    new string[512];

    for (new i=0; i < sizeof(arenas); i++)
    {
        for (new j=0; j < sizeof(arenas); j++)
        {  
            strcat(string, sprintf("%s\t%s\n", arenas[i][j], arenas[i][j], sizeof(string)));
        }
    }

    Dialog_Show(playerid, ArenasList, DIALOG_STYLE_MSGBOX, "Arena Teaming Rules", string, "OK", "OK");
    return 1;
}
I'm new, and I understand that you're probably cringing reading my code right now. I really appreciate your help regardless. Cheers!

Just to clarify, I want the array to be inserted into the dialog box so it outputs the contents of the array into the box.
Reply
#2

In this case you don't need a second loop, it's enough:
PHP Code:
for (new 0sizeof(arenas); i++){
    
format(stringsizeof string"%s%s\t%s\n"stringarenas[i][0], arenas[i][1]);

Reply
#3

do you use that array somewhere else?, in your example you could put the text (with the correct formation) directly into Dialog_Show
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)