Skip to content

Commit

Permalink
Merge pull request #3 from Nickk888SAMP/3.0.0
Browse files Browse the repository at this point in the history
3.0.0
  • Loading branch information
Nickk888SAMP authored Jun 9, 2022
2 parents e104adb + 6edb5df commit b5d2d25
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 81 deletions.
83 changes: 35 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Nickk's Dialog Pages
<img src="/preview.gif" width="400" height="400">

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!
Nickk's Dialog Pages adds the possibility to created paged dialog lists.

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 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.
It is very easy to use, because everything is fully automatic.

## Installation

Expand Down Expand Up @@ -38,55 +37,43 @@ Resets the lister for the dialog.
```pawn
ClearDialogListitems(playerid);
```
Shows the dialog.
Shows the dialog
```pawn
ShowPlayerDialog(playerid, dialogid, style, caption[], #, button1[], button2[], items_per_page = 0, nextbutton[] = "{FF0000}>>>", backbutton[] = "{FF0000}<<<");
ShowPlayerDialogPages(playerid, const function[], style, const caption[], const button1[], const button2[], items_per_page, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
```

Shows the dialog (Legacy, Deprecated)
```pawn
ShowPlayerDialog(playerid, dialogid, style, const caption[], #, const button1[], const button2[], items_per_page = 0, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
```

## How to Use
Before showing the dialog for the player, you need to add the items into the dialog using the "`AddDialogListitem`" function without "`\n`"!
After you added all the items (Using a loop or manually) you need to use the "`ShowPlayerDialog`" function.
The "`info[]`" parameter will not be used so you can just put an empty string or a "`#`" inside it.
To make the dialog split the items into multiple pages, you will need to first set the "`items_per_page`" parameter > 0.
"`items_per_page`" will tell the dialog, how many items will fit into ONE page!
Set it to 10, it will show you 10 items plus the "`Next`" and "`Back`" button.
You can also modify the buttons yourself, just set the "nextbutton" and or "backbutton" parameter, but that's optional.
Also check if "listitem" is NOT "`INVALID_LISTITEM`", it will be invalid if the player will press the "`Next`" or "`Back`" button, so please negate it!
To add items to a paged dialog, use the function "```AddDialogListitem```".
* ```playerid``` - The player you want to add items to the dialog.
* ```itemstring[]``` - The item as a string without ```\n```

After the dialog has been showed to the player, using the "`AddDialogListitem`" function will completely reset the items and it will add the new item from index 0 >
You can also FORCE reseting the dialog lister using the "`ClearDialogListitems`" function if you need to.
To show the paged dialog, use function "```ShowPlayerDialogPages```".
* ```playerid``` - The player you want to show the dialog.
* ```function[]``` - The name of the Dialog, must be the same as defined with "DialogPages:".
* ```style``` - The style of the dialog.
* ```caption[]``` - The caption of the dialog.
* ```button1[]``` - The first button of the dialog.
* ```button2[]``` - The second button of the dialog
* ```items_per_page``` - The amount of items showed on a single page.
* ```nextbutton[]``` - The "Next" button string. (Optional)
* ```backbutton[]``` - The "Back" button string. (Optional)

You can change the amount of max items in your dialog by redefining the "`MAX_DIALOG_ITEMS`" definition.
If you want to clear the ```Items Cache```, you can always use ```ClearDialogListitems(playerid)```, it's optional because it's always cleared when the first item has been added after a paged dialog has been showed to the player.

## Example
* DIALOG_STYLE_LIST
```pawn
new ndp_e_str[128];
for(new i; i < MAX_DIALOG_ITEMS; i++)
{
format(ndp_e_str, sizeof ndp_e_str, "{FFFFFF}List Item {FF00FF}%i", i);
AddDialogListitem(playerid, ndp_e_str);
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 15);
```
* DIALOG_STYLE_TABLIST
```pawn
new ndp_e_str[128];
for(new i; i < MAX_DIALOG_ITEMS; i++)
DialogPages:DialogName(playerid, response, listitem)
{
format(ndp_e_str, sizeof ndp_e_str, "{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i", i, i, i, i);
AddDialogListitem(playerid, ndp_e_str);
new dstr[128];
format(dstr, sizeof dstr, "{FFFF00}[NDialog-Pages] {FFFFFF}You have selected listitem ID: {FFFF00}%i", listitem);
SendClientMessage(playerid, -1, ndp_e_str);
return 1;
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_TABLIST, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 27);
```
* DIALOG_STYLE_TABLIST_HEADERS
```pawn
new ndp_e_str[128];
AddDialogListitem(playerid, "{FFFFFF}Column 1\t{FF00FF}Column 2\t{FFFF00}Column 3\t{00FFFF}Column 4");
for(new i; i < MAX_DIALOG_ITEMS; i++)
{
format(ndp_e_str, sizeof ndp_e_str, "{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i\t{FFFFFF}List Item {FF00FF}%i", i, i, i, i);
AddDialogListitem(playerid, ndp_e_str);
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 32);
```

## Example
[Example Script](https://github.com/Nickk888SAMP/Dialog-Pages/blob/master/ndp_examples.pwn)
Loading

0 comments on commit b5d2d25

Please sign in to comment.