Dynamically adding/removing items in list dialogues.
#5

You'll need to format your dialog contents in a string.
Then you can use if-statements if you want some items excluded from the list.
pawn Код:
new TItem
{
    ItemName[24],
    ValidItem
}
new AItems[][TItem] =
{
    {"Item1", 1},
    {"Item2", 1},
    {"Item3", 1},
    {"Item4", 1},
    {"Item5", 1},
    {"Item6", 1},
    {"Item7", 0},
    {"Item8", 1},
    {"Item9", 0},
    {"Item10", 1},
    {"Item11", 1},
    {"Item12", 0},
    {"Item13", 1},
    {"Item14", 1}
}



new string[512];
for (new i; i < sizeof(AItems); i++)
{
    if (AItems[i][ValidItem] == 1)
    {
        format(String, sizeof(String), "%s%s\n", String, AItems[i][ItemName]);
    }

    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "List of valid items", String, "Select", "Cancel")
}
Something like this will do it.
In this code, Item7, Item9 and Item12 won't be added to the list as they're invalid items.

But editing a dialog while it's being displayed already isn't possible.
You could however, update the string and re-display the dialog to update it's contents.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)