Solved Online Player Selector GUI

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Apr 22, 2020
48
4
8
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:
#
#
#   /punish
#
#
on join:
        add player to {Online::*}
        add 1 to {Count}
        if {Count} = 1:
                set {P1} to the first element out of {Online::*}
        if {Count} = 2:
                set {P2} to random object out of {Online::*}
        if {Count} = 3:
                set {P3} to the third element out of {Online::*}
        if {Count} = 4:
                set {P4} to the fourth element out of {Online::*}
        if {Count} = 5:
                set {P5} to the fifth element out of {Online::*}

on disconnect:
    remove player from {Online::*}
    remove 1 from {Count}

command /liste:
    trigger:
        send "%{P1}%"
        send "%{P2}%"
        send "%{P3}%"
        send "%{P4}%"
        send "%{P5}%"



command /cerberus:
    trigger:
        if player does not have the permission "permission.cerberus":
            send "&8» &cPermission &8| &7You do not have access to this!"
            exit
        create a gui with virtual chest with 6 rows named " ":
            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."
            if {_Slot} is not set:
                set {_Slot} to 43
                {_Slot} < 45
                make gui slot {_Slot}+1 with {P1}'s skull named "&b%{P1}%" with lore "&7" and "&7Click to punish %{P1}'s name%":
                    make player execute command "punish %{P1}%"
                make gui slot 50 with arrow named "&ePage 2":
                    create a gui with virtual chest with 6 rows named " ":
                        set {_Slot} to 8
                        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."
                        make gui slot {_Slot}+1 with {P2}'s skull named "&b%{P2}%" with lore "&7" and "&7Click to punish %{P2}'s name%":
                            make player execute command "punish %{P2}%"
                    open last gui to player
        open last gui to player
        exit
 
when you open the gui:
Code:
set {_slot} to 0
loop all players:
    if loop-player != player:
        make gui slot {_slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
            player command "punish %loop-player%"
        add 1 to {_slot}
 
Code:
command /cerberus:
    trigger:
        if player does not have the permission "permission.cerberus":
            send "&8» &cPermission &8| &7You do not have access to this!"
            exit
        set {_Slot} to 0
        loop all players:
            if loop-player != player:
                make gui slot {_Slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
                    player command "punish %loop-player%"
                add 1 to {_Slot}
        create a gui with id "cerberus" with virtual chest with 6 rows named " ":
            loop integers between 0 and 53:
                make gui slot loop-integer with air
            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."
            if {_Slot} is not set:
                set {_Slot} to 43
                {_Slot} < 45
                make gui slot {_Slot}+1 with {P1}'s skull named "&b%{P1}%" with lore "&7" and "&7Click to punish %{P1}'s name%":
                    make player execute command "punish %{P1}%"
                make gui slot 50 with arrow named "&ePage 2":
                    create a gui with virtual chest with 6 rows named " ":
                        loop integers between 0 and 53:
                            make gui slot loop-integer with air
                        set {_Slot} to 8
                        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."
                        make gui slot {_Slot}+1 with {P2}'s skull named "&b%{P2}%" with lore "&7" and "&7Click to punish %{P2}'s name%":
                            make player execute command "punish %{P2}%"
                    open last gui to player
        open last gui to player
        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:
[doublepost=1587601769,1587596987][/doublepost]
when you open the gui:
Code:
set {_slot} to 0
loop all players:
    if loop-player != player:
        make gui slot {_slot} with loop-player's skull named "&b%loop-player%" with lore "&7" and "&7Click to punish %loop-player%" to run:
            player command "punish %loop-player%"
        add 1 to {_slot}
oops i didnt reply. hopefully this gets your attention almighty Dave
 
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.
 
Status
Not open for further replies.