SA-MP Forums Archive
Dialog that grows automatically - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dialog that grows automatically (/showthread.php?tid=568575)



Dialog that grows automatically - Derexi - 23.03.2015

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"?


Re: Dialog that grows automatically - Vince - 23.03.2015

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.


Respuesta: Dialog that grows automatically - alexus - 23.03.2015

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.


Re: Dialog that grows automatically - Derexi - 23.03.2015

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.