What and how is the concept of creating dynamic Dialogs (listitems)
#1

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

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

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

It should work, yes.
Reply
#5

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
Reply
#6

Glad it helped!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)