23.12.2018, 12:38
(
Last edited by Nickk888; 04/06/2020 at 01:46 PM.
Reason: New version
)
About Include:
NDialog-Pages is basically an addon that adds 3 additional options to the "ShowPlayerDialog" function. It will add a feature so that you can split the dialog list into multiple pages!
It will basically calculate how many items will fit into one page and generate the "Next" button if there are too many. It will also add a "Back" button if you go to the second page etc. It will calculate the "listitem" in such way, like a normal list would work, so you don't need to make some calculation yourself, everything is automatic and it will return the correct "listitem".
It is VERY easy to use, because everything is fully automatic.
Features:
- Adds 3 new parameters to "ShowPlayerDialog"
- Easy to use!
- Fully customable.
- Fully automatic, no need to script page change.
Code:
AddDialogListitem(playerid, const itemstring[]);
Code:
ClearDialogListitems(playerid);
Code:
ShowPlayerDialog(playerid, dialogid, style, caption[], #, button1[], button2[], items_per_page = 0, nextbutton[] = "{FF0000}>>>", backbutton[] = "{FF0000}<<<");
Code:
items_per_page - Items inside a page nextbutton[] - "Next" button string backbutton[] - "Back" button string
Code:
#include <a_samp> #include <zcmd> #define MAX_DIALOG_ITEMS 500 #include <ndialog-pages> new string[256]; CMD:dialogtest(playerid, params[]) { for(new i; i < MAX_DIALOG_ITEMS; i++) { format(string, sizeof string, "{FFFFFF}List Item {FF00FF}%i", i); AddDialogListitem(playerid, string); } ShowPlayerDialog(playerid, 586, DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 25); return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 586 && response) { if(listitem != INVALID_LISTITEM) { format(string, sizeof string, "{FFFFFF}[NDialog-Pages] {FFFF00}You have selected listitem ID: %i", listitem); SendClientMessage(playerid, -1, string); } } return 0; }
Code:
#define INVALID_LISTITEM -1
V2.0: https://github.com/Nickk888SAMP/Dialog-Pages
Credits:
a_samp: SAMP Team
Y_Hooks: Y-Less