[Include] NDIALOG-PAGES - Split dialog lists into multiple pages!
#1



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.
Functions:
Code:
AddDialogListitem(playerid, const itemstring[]);
Code:
ClearDialogListitems(playerid);
Code:
ShowPlayerDialog(playerid, dialogid, style, caption[], #, button1[], button2[], items_per_page = 0, nextbutton[] = "{FF0000}>>>", backbutton[] = "{FF0000}<<<");
Parameters:
Code:
items_per_page - Items inside a page
nextbutton[] - "Next" button string
backbutton[] - "Back" button string
How to use it(Examples):
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;
}
Defines:
Code:
#define INVALID_LISTITEM -1
Download:
V2.0: https://github.com/Nickk888SAMP/Dialog-Pages

Credits:
a_samp: SAMP Team
Y_Hooks: Y-Less
Reply
#2

Nice
Reply
#3

Nice idea
Reply
#4

Nicely done c:
Reply
#5

I will definetly be using this in the future, nice release.
Reply
#6

works with easyDialog?
Reply
#7

Quote:
Originally Posted by Smith.
View Post
works with easyDialog?
I have no idea, probably? You would have to check it. The problem with Easy Dialog is, it doesn't support the 3 additional parameters, so you would need to modify Easy Dialog for your needs.
Reply
#8

Thanks, good work
Reply
#9

BUMP - Code has been rewritten, version 2.0
Download >>> https://github.com/Nickk888SAMP/Dialog-Pages <<<
Reply
#10

Quote:
Originally Posted by Nickk888
View Post
BUMP - Code has been rewritten, version 2.0
Download >>> https://github.com/Nickk888SAMP/Dialog-Pages <<<
Code:
include\ndialog-pages.inc(131) : error 035: argument type mismatch (argument 4)
\ndialog-pages.inc(154) : error 035: argument type mismatch (argument 4)

line 131: ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
I wonder why const variable in parameter make this error.

@EDIT: Working fine tho but then I check my server.log it shows me this.
Code:
[02:30:26] [debug]
[02:30:26] [debug] Parameter count corrections:
[02:30:26] [debug]
[02:30:26] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:26] [debug]
[02:30:26] [debug] Run time error 4: "Array index out of bounds"
[02:30:26] [debug]  Attempted to read/write array element at negative index -2
[02:30:26] [debug] AMX backtrace:
[02:30:26] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:26] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:31] [debug]
[02:30:31] [debug] Parameter count corrections:
[02:30:31] [debug]
[02:30:31] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:31] [debug]
[02:30:31] [debug] Run time error 4: "Array index out of bounds"
[02:30:31] [debug]  Attempted to read/write array element at negative index -2
[02:30:31] [debug] AMX backtrace:
[02:30:31] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:31] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:36] [debug]
[02:30:36] [debug] Parameter count corrections:
[02:30:36] [debug]
[02:30:36] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:36] [debug]
[02:30:36] [debug] Run time error 4: "Array index out of bounds"
[02:30:36] [debug]  Attempted to read/write array element at negative index -2
[02:30:36] [debug] AMX backtrace:
[02:30:36] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:36] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:40] [debug]
[02:30:40] [debug] Parameter count corrections:
[02:30:40] [debug]
[02:30:40] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:40] [debug]
[02:30:40] [debug] Run time error 4: "Array index out of bounds"
[02:30:40] [debug]  Attempted to read/write array element at negative index -2
[02:30:40] [debug] AMX backtrace:
[02:30:40] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:40] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:48] [debug]
[02:30:48] [debug] Parameter count corrections:
[02:30:48] [debug]
[02:30:48] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
Reply
#11

Quote:
Originally Posted by ToiletDuck
View Post
Code:
include\ndialog-pages.inc(131) : error 035: argument type mismatch (argument 4)
\ndialog-pages.inc(154) : error 035: argument type mismatch (argument 4)

line 131: ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
I wonder why const variable in parameter make this error.

@EDIT: Working fine tho but then I check my server.log it shows me this.
Code:
[02:30:26] [debug]
[02:30:26] [debug] Parameter count corrections:
[02:30:26] [debug]
[02:30:26] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:26] [debug]
[02:30:26] [debug] Run time error 4: "Array index out of bounds"
[02:30:26] [debug]  Attempted to read/write array element at negative index -2
[02:30:26] [debug] AMX backtrace:
[02:30:26] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:26] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:31] [debug]
[02:30:31] [debug] Parameter count corrections:
[02:30:31] [debug]
[02:30:31] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:31] [debug]
[02:30:31] [debug] Run time error 4: "Array index out of bounds"
[02:30:31] [debug]  Attempted to read/write array element at negative index -2
[02:30:31] [debug] AMX backtrace:
[02:30:31] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:31] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:36] [debug]
[02:30:36] [debug] Parameter count corrections:
[02:30:36] [debug]
[02:30:36] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:36] [debug]
[02:30:36] [debug] Run time error 4: "Array index out of bounds"
[02:30:36] [debug]  Attempted to read/write array element at negative index -2
[02:30:36] [debug] AMX backtrace:
[02:30:36] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:36] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:40] [debug]
[02:30:40] [debug] Parameter count corrections:
[02:30:40] [debug]
[02:30:40] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[02:30:40] [debug]
[02:30:40] [debug] Run time error 4: "Array index out of bounds"
[02:30:40] [debug]  Attempted to read/write array element at negative index -2
[02:30:40] [debug] AMX backtrace:
[02:30:40] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=-2, inputtext[]=@4fd59dd0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[02:30:40] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 1339399632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[02:30:48] [debug]
[02:30:48] [debug] Parameter count corrections:
[02:30:48] [debug]
[02:30:48] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
I have probably fixed that error in my code, please consider redownloading the include from the github page!
Reply
#12

Quote:
Originally Posted by Nickk888
View Post
I have probably fixed that error in my code, please consider redownloading the include from the github page!
> Did you negate the listitem before using the index in your script? Looks like you didn't do that so even though you press the Next and Back button, it will still call OnDialogResponse using -2 as the listitem. I have changed the Value inside the include so give it a try, check if you negate the dialog! Look at the example script i provided.

Hi still I downloaded your latest the error still occurs. Whenever I press Next or Prev.

Code:
[09:18:12] [debug]
[09:18:12] [debug] Parameter count corrections:
[09:18:12] [debug]
[09:18:12] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[09:18:12] [debug]
[09:18:12] [debug] Run time error 4: "Array index out of bounds"
[09:18:12] [debug]  Attempted to read/write array element at index 65535 in array of size 50
[09:18:12] [debug] AMX backtrace:
[09:18:12] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=65535, inputtext[]=@1e9ff5d0 ">>>") at ./includes/OnDialogResponse.pwn:3233
[09:18:12] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 10, 513799632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
[09:18:13] [debug]
[09:18:13] [debug] Parameter count corrections:
[09:18:13] [debug]
[09:18:13] [debug] The 1st mangled argments (e.g. `<1073741823 arguments>`) below should read `<5 arguments>`
[09:18:13] [debug]
[09:18:13] [debug] Run time error 4: "Array index out of bounds"
[09:18:13] [debug]  Attempted to read/write array element at index 65535 in array of size 50
[09:18:13] [debug] AMX backtrace:
[09:18:13] [debug] #0 006f791c in OnDialogResponse (playerid=0, dialogid=6182, response=1, listitem=65535, inputtext[]=@1e9ff5d0 "<<<") at ./includes/OnDialogResponse.pwn:3233
[09:18:13] [debug] #1 0001789c in public OnDialogResponse (0, 6182, 1, 8, 513799632) at D:\05_Desktop\EGRP-master\pawno\include\YSI_Coding\y_timers\..\..\YSI_Data\y_foreach\..\..\YSI_Coding\y_hooks\..\y_cgen\y_cgen.inc:127
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)