Dialog that grows automatically
#1

For example, say I want to load 50 races from my database, then display them in a list dialog. 50 races will make a huge dialog, so I'd need more dialogs with "next" and "previous" buttons on them. Say I wanted to show 8 races on each dialog, how would I split my races into 8 and put them into different dialogs with "next" or "previous"?
Reply
#2

PHP код:
SELECT foo FROM bar LIMIT 0
Where 0 is the row index you want to start from, and 8 is the number of rows you want to fetch. The next queries will then be:
8,8
16,8
24,8
32,8
etc

Of course easily calculated by doing page * 8.
Reply
#3

make a command /races [n] (n= 1, 2, 3...)

Код:
dcmd_races(playerid, params[])
{
     if (params[0] == '1' && params[1] == '\0' )
     {
          // show your first dialog (races 1 to 8)
          return 1;
     }
     else if ( params[0] == '2' && params[1] == '\0' )
     {
          // show your second dialog (races 9 to 16)
          return 1;
     }
     ...
     ...
     else if ( params[0] == 'n' && params[1] == '\0' )
     {
          // show your n dialog  (races 8*(n-1) to last)
          return 1;
     }
     else return SendUsage( playerid, "/races [1 to n]" );
}
n depends of the total races. In your case you need 7 dialogs, the last with only two races (8*6)+2 = 50 races, so n=7.

This solution is not very good because you need to edit the script everytime you add a new race.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
PHP код:
SELECT foo FROM bar LIMIT 0
Where 0 is the row index you want to start from, and 8 is the number of rows you want to fetch. The next queries will then be:
8,8
16,8
24,8
32,8
etc

Of course easily calculated by doing page * 8.
Thanks! Just finished creating the dialog and it works perfectly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)