1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Online Player Selector GUI

Discussion in 'Skript' started by AHappyLittleSloth, Apr 22, 2020.

Thread Status:
Not open for further replies.
  1. AHappyLittleSloth

    Joined:
    Apr 22, 2020
    Messages:
    48
    Likes Received:
    4
    So I've only been using Skript for the past 3 days but here is the Skript I'm working on (I know the code is horrible atm). So I'm creating a custom punishment system and when the player types /cerberus it pops up with a GUI with players online. The concept is that it creates a variable list with all online players, then it calls upon each player name in the list, displaying the corresponding heads in slots 9-44 (There will be navigational buttons in the GUI so these are the slots that can contain heads), then stopping at slot 44, and on the next page it resumes. If possible I would like the heads in alphabetical order but idk if it's possible with list variables. I'm pretty close and my skript works (ish).


    Code (Text):
    1. #
    2. #
    3. #   /punish
    4. #
    5. #
    6. on join:
    7.         add player to {Online::*}
    8.         add 1 to {Count}
    9.         if {Count} = 1:
    10.                 set {P1} to the first element out of {Online::*}
    11.         if {Count} = 2:
    12.                 set {P2} to random object out of {Online::*}
    13.         if {Count} = 3:
    14.                 set {P3} to the third element out of {Online::*}
    15.         if {Count} = 4:
    16.                 set {P4} to the fourth element out of {Online::*}
    17.         if {Count} = 5:
    18.                 set {P5} to the fifth element out of {Online::*}
    19.  
    20. on disconnect:
    21.     remove player from {Online::*}
    22.     remove 1 from {Count}
    23.  
    24. command /liste:
    25.     trigger:
    26.         send "%{P1}%"
    27.         send "%{P2}%"
    28.         send "%{P3}%"
    29.         send "%{P4}%"
    30.         send "%{P5}%"
    31.  
    32.  
    33.  
    34. command /cerberus:
    35.     trigger:
    36.         if player does not have the permission "permission.cerberus":
    37.             send "&8» &cPermission &8| &7You do not have access to this!"
    38.             exit
    39.         create a gui with virtual chest with 6 rows named " ":
    40.             make gui slot 4 with nether star named "&cSelect A Player To Punish" with lore "&7You will then be prompted to", "&7select a type, reason, and duration" and "&7for the punishment."
    41.             if {_Slot} is not set:
    42.                 set {_Slot} to 43
    43.                 {_Slot} < 45
    44.                 make gui slot {_Slot}+1 with {P1}'s skull named "&b%{P1}%" with lore "&7" and "&7Click to punish %{P1}'s name%":
    45.                     make player execute command "punish %{P1}%"
    46.                 make gui slot 50 with arrow named "&ePage 2":
    47.                     create a gui with virtual chest with 6 rows named " ":
    48.                         set {_Slot} to 8
    49.                         make gui slot 4 with nether star named "&cSelect A Player To Punish" with lore "&7You will then be prompted to", "&7select a type, reason, and duration" and "&7for the punishment."
    50.                         make gui slot {_Slot}+1 with {P2}'s skull named "&b%{P2}%" with lore "&7" and "&7Click to punish %{P2}'s name%":
    51.                             make player execute command "punish %{P2}%"
    52.                     open last gui to player
    53.         open last gui to player
    54.         exit
    55.  


     
  2. Best Answer:
    Post #4 by Blue, Apr 23, 2020
  3. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    when you open the gui:
    Code (Text):
    1. set {_slot} to 0
    2. loop all players:
    3.     if loop-player != player:
    4.         make gui slot {_slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
    5.             player command "punish %loop-player%"
    6.         add 1 to {_slot}
     
  4. AHappyLittleSloth

    Joined:
    Apr 22, 2020
    Messages:
    48
    Likes Received:
    4
    Code (Text):
    1. command /cerberus:
    2.     trigger:
    3.         if player does not have the permission "permission.cerberus":
    4.             send "&8» &cPermission &8| &7You do not have access to this!"
    5.             exit
    6.         set {_Slot} to 0
    7.         loop all players:
    8.             if loop-player != player:
    9.                 make gui slot {_Slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
    10.                     player command "punish %loop-player%"
    11.                 add 1 to {_Slot}
    12.         create a gui with id "cerberus" with virtual chest with 6 rows named " ":
    13.             loop integers between 0 and 53:
    14.                 make gui slot loop-integer with air
    15.             make gui slot 4 with nether star named "&cSelect A Player To Punish" with lore "&7You will then be prompted to", "&7select a type, reason, and duration" and "&7for the punishment."
    16.             if {_Slot} is not set:
    17.                 set {_Slot} to 43
    18.                 {_Slot} < 45
    19.                 make gui slot {_Slot}+1 with {P1}'s skull named "&b%{P1}%" with lore "&7" and "&7Click to punish %{P1}'s name%":
    20.                     make player execute command "punish %{P1}%"
    21.                 make gui slot 50 with arrow named "&ePage 2":
    22.                     create a gui with virtual chest with 6 rows named " ":
    23.                         loop integers between 0 and 53:
    24.                             make gui slot loop-integer with air
    25.                         set {_Slot} to 8
    26.                         make gui slot 4 with nether star named "&cSelect A Player To Punish" with lore "&7You will then be prompted to", "&7select a type, reason, and duration" and "&7for the punishment."
    27.                         make gui slot {_Slot}+1 with {P2}'s skull named "&b%{P2}%" with lore "&7" and "&7Click to punish %{P2}'s name%":
    28.                             make player execute command "punish %{P2}%"
    29.                     open last gui to player
    30.         open last gui to player
    31.         exit

    Its returning that there is no loop-player skull named %loop-player%...

    On line :
    make gui slot {_Slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
    --- Double Post Merged, Apr 23, 2020, Original Post Date: Apr 23, 2020 ---
    oops i didnt reply. hopefully this gets your attention almighty Dave
     
  5. Blue

    Moderator Supporter ++

    Joined:
    Apr 15, 2018
    Messages:
    30
    Likes Received:
    5
    You'd want to look into first getting a list of names from the online players, then sorting them using the Alphabetical Sort expression, then splitting them into more lists, with a size of 35 for each, and finally displaying the list corresponding to the current page with the Player Skull expression.

    I believe TuSKe is also no longer under development, so vanilla Skript GUIs are recommended. You can find a tutorial on them here.
     
    • Agree Agree x 2
Thread Status:
Not open for further replies.

Share This Page

Loading...