Dynamically adding/removing items in list dialogues.
#1

Hi,

Could somebody please tell me how to dynamically add items or to or remove items from a list dialog (if possible)? If it is not possible, could you please provide a reasonable alternative?


Thanks.
Reply
#2

What kind of items you use ?
Reply
#3

I don't mean items literally. I was just talking about adding things to list dialogs on the fly. So, instead of...
Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Cellphone Menu", "Send Message\n View Messages", "Select", "Cancel")
...I was hoping to be able to use something similar to 'list.additem' in other programming languages.
Reply
#4

It doesn't really work that way you would have to show the dialog again with the removed item so it will be flashy your actually better off using textdraws in my view dialogs have their uses but textdraws handle what you want to do much better.
Reply
#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
#6

We need to see the dialogs..
Reply
#7

Quote:
Originally Posted by Clad
Посмотреть сообщение
We need to see the dialogs..
No you don't, why post if you're not going to help? OP's question was asking HOW to do it. Power's post seems to make sense, though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)