What and how is the concept of creating dynamic Dialogs (listitems) -
denNorske - 02.06.2015
Okay, so
I was wondering about how a dynamic, SQL based in my case, dialog would work.
I have no problem creating the data for the dialog itself, but I'm a bit stuck on how to add "listitems" to the dialog-
Can someone provide me a basic method on how to do this, briefly? I just need to understand how it's done, so there is no need for huge examples.
I was thinking about creating a row in the DB with the dialog-list items, and thereafter create a loop to loop through the names and that way, be able to create items etc. How to get "\n"?
Thanks for any help
Re: What and how is the concept of creating dynamic Dialogs (listitems) -
Abagail - 02.06.2015
I'd recommend using Vince's method of storing one list item per dialog ID and then you can easily loop through the returned data, and input "\n" into a combined string. For instance,
pawn Код:
new idx, dialogname[MAX_DIALOG_NAME], listitem[rows];
while(idx < rows)
{
cache_get_field_content(idx, "ListItemText", listitem[idx], swlConnection);
format(smallstr, "%s\n", listitem[idx]);
strcat(string, smallstr, sizeof(string));
}
ShowPlayerDialog(playerid, DIALOG_DYNAMIC_ID, DIALOG_TYPE_LIST, dialogname, string, "button 1", "button 2");
Ofcourse this is in no way a complete example. This just shows one way of loading the data, and showing it as a dialog string.
Re: What and how is the concept of creating dynamic Dialogs (listitems) -
Luis- - 02.06.2015
Sorry to just hijack this thread, but would the same method work for loading a list of server rules from a MySQL database and loading them into a dialog?
Re: What and how is the concept of creating dynamic Dialogs (listitems) -
Abagail - 02.06.2015
It should work, yes.
Re: What and how is the concept of creating dynamic Dialogs (listitems) -
denNorske - 02.06.2015
Quote:
Originally Posted by Abagail
I'd recommend using Vince's method of storing one list item per dialog ID and then you can easily loop through the returned data, and input "\n" into a combined string. For instance,
pawn Код:
new idx, dialogname[MAX_DIALOG_NAME], listitem[rows]; while(idx < rows) { cache_get_field_content(idx, "ListItemText", listitem[idx], swlConnection);
format(smallstr, "%s\n", listitem[idx]); strcat(string, smallstr, sizeof(string)); } ShowPlayerDialog(playerid, DIALOG_DYNAMIC_ID, DIALOG_TYPE_LIST, dialogname, string, "button 1", "button 2");
Ofcourse this is in no way a complete example. This just shows one way of loading the data, and showing it as a dialog string.
|
Thank you! This explains it the way I was assuming it would be, very helpful-
And weird, I had a hard time finding any good examples, oh well.
Solved this one
Re: What and how is the concept of creating dynamic Dialogs (listitems) -
Abagail - 02.06.2015
Glad it helped!