Report list with pages

Discussion in 'Skript' started by Miss_Wafffidooe, May 18, 2020.

  1. Heyy, I have here a small sequence of my report skript. The only thing I'd like to add, is so that on the top, it says "page (x) of (z) ... I only want 10 reports shown per page. How do i do that?

    Code (Text):
    command /reports:
        permission: reports.list
            if size of {reports::*} is greater than 0:
                message "&3The following players have been reported:"
                loop {reports::*}:
                    message "%loop-value%"
                message "&2No players have been reported - yay!"
  2. You would have to get 10 reports at a time and then send them each time a player executes the command with a page number.

    Can you also put [Skript] in the title next time because I am a java dev and going through to help others and then finding skript is a bit annoying. Thanks
  3. But I don't know how to do that at all... ahaha sorry

    To the EDIT - sure ;)
  4. I'd index reports by a number
    then show only between {reports::1} and {reports::10} for 1st page
    then between {reports::10} and {reports::20} for 2nd page and so on

    you could do this by math,
    set {_max} to {_page} * 10
    set {_min} to {_max}-10
  5. How do I set this up in code? Sorry, haven't tried this before
    #5 Miss_Wafffidooe, May 18, 2020
    Last edited: May 18, 2020
  6. But there shall only be a second page if at least 11 reports have been added... I'm so lost on this ahaha - how do I do it?
  7. I have this code snippet for automatically creating multi-paged guis:
    Code (Text):

    function multipagegui(p: player, name: text, page: number = 1) :: numbers:
       open chest with 6 rows named colored "%{_name}%" to {_p}
       if {_page} is not 1:
           set {_name} to "&aPrevious Page %{_page}-1%"
           set {_name} to "&aGo back"
       set slot 45 of {_p}'s current inventory to arrow named {_name}
       if {_page} is 1:
           set {_min} to 1
           set {_max} to 46
           #used for 2+ pages
           set {_min} to 46
           set {_max} to 91
       if {_page} is higher than 2:
           set {_max} to {_max}+(45*({_page}-2))
           set {_min} to {_max}-45
       return {_min} and {_max}
    it returns two numbers, one is the min index and other is max index, so in a variable of {_list::*} which is indexed by numbers, you can use loop integers from {_min} to {_max} and then {_list::%loop-number%}

    example of one place I use this code in:

    Code (Text):

    command /furnituregui [<integer>]:
           player's gamemode is creative
           set {_integers::*} to multipagegui(player, "&a- &6&lFurniture &a-", (arg 1 ? 1))
           inventory name of player's current inventory = "&a- &6&lFurniture &a-"
           set {_inventory} to player's current inventory
           set slot 49 of {_inventory} to a sign item named "&eSearch.."
           set {_loops} to 0
           loop numbers from {_integers::1} to {_integers::2}:
               {furniture::%loop-number%} is set:
                   if loop-number is {_integers::2}:
                       set slot 53 of player's current inventory to arrow named "&aNext Page %(arg 1 ? 1)+1%"
                   set slot {_loops} of {_inventory} to {furniture::%loop-number%}
                   add 1 to {_loops}
                   add 1 to {_notset}
                   {_notset} is higher than 1:
                       send "&cAn error occurred while generating this menu. Report this to Govindas."

    on inventory click:  
       inventory name of player's current inventory = "&a- &6&lFurniture &a-"
       player's gamemode is creative
       clicked inventory is not player's inventory
       clicked item is a arrow:
           set {_n} to uncolored name of clicked item
           {_n} contains "Page":
               replace all "Next Page " and "Previous Page " with "" in {_n}
               set {_n} to {_n} parsed as a integer
               make player execute command "/furnituregui %{_n}%"
           else if {_n} is "Go back":
               make player execute command "/creativemenuutils"
           cancel event
       else if clicked item is a sign:
           cancel event
           close player's inventory
           signGUI(player, "/furnituresearch", "", "&a ^", "&a ^^^", "&aFurniture Name")