Help with 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.

xTarheel

Member
Jan 28, 2017
14
0
0
24
So I made this

code_language.skript:
command /Crystals [<player>]:
    aliases: crystal,c
    trigger:
        if {Crystals::%player%} is not set:
            set {Crystals::%player%} to 0
        if {Crystals::%player%} is -1:
            set {Crystals::%player%} to 0
        if arg 1 is not set:
            message "&8You have &b%{Crystals::%player%}% Crystals."
        else:
            message "&8%arg 1% has &b%{Crystals::%player%}% Crystals."

command /cshop:
    trigger:
        open chest with 3 rows named "&9Crystals&bShop" to player
        format slot 4 of player with arg 1's skull named "%player%" with lore "&cThats you!" to be unstealable
        format slot 11 of player with nether star named "&eAccess to /feed" to run [pex user %Player% add essentials.feed]

I need it to be like when you click the nether star it takes 50 crystals away from you and gives you access to /feed, but im lost. Very lost
 
Well first line 17 is not correct. It goes like this:
code_language.skript:
 format slot 11 of player with nether star named "&eAccess to /feed" to run "pex user %Player% add essentials.feed"

Also you would have to make it run a command that runs the pex command and removes 50 from your crystals variable. Like this:
code_language.skript:
command /crystalshoprem <player> <text>:
    trigger:
        if arg 2 is "feed":
            if {Crystals::%arg 1%} is not less than 50:
                remove 50 from {Crystals::%arg 1%}
                execute console command "pex user %arg 1% add essentials.feed"
                send "&aYou have bought the /feed command for 50 crystals!" to arg 1
            else:
                send "&cYou don't have enough crystals!" to arg 1
 
  • Like
Reactions: xTarheel
Well first line 17 is not correct. It goes like this:
code_language.skript:
 format slot 11 of player with nether star named "&eAccess to /feed" to run "pex user %Player% add essentials.feed"

Also you would have to make it run a command that runs the pex command and removes 50 from your crystals variable. Like this:
code_language.skript:
command /crystalshoprem <player> <text>:
    trigger:
        if arg 2 is "feed":
            if {Crystals::%arg 1%} is not less than 50:
                remove 50 from {Crystals::%arg 1%}
                execute console command "pex user %arg 1% add essentials.feed"
                send "&aYou have bought the /feed command for 50 crystals!" to arg 1
            else:
                send "&cYou don't have enough crystals!" to arg 1
Ok, thanks :emoji_slight_smile:
 
Ok, thanks :emoji_slight_smile:
I understand that you have found a solution to your problem, but that isn't the best way to do it, as that allows for unnecessary commands and the use of format slot, which isn't the best option for GUIs.

I would suggest using set slot to format your GUIs. For example, something like:
code_language.skript:
set slot 5 of player's current inventory to stone named "&7Hey" with lore "Heyyyy"

Then, you would use the on inventory click event to trigger certain functions.
For example:
code_language.skript:
on inventory click:
    if inventory name of player's current inventory is " "
    # Check the name of the player's inventory against a value.
    # Replace the spaces with the name of your inventory. For example, "&9Shop."
        if clicked slot is 44:
        # Check the slot the player clicked against a value.
            doStuff(player)
Will this, you can also check against and grab the name and lore of the item that the player clicked. You could also build your function directly into the inventory click event.
 
Status
Not open for further replies.