Solved /Buy Command help

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

ZsCortzones

Member
Feb 18, 2021
32
1
8
26
I am trying to Skript a /buy command so my players can easily access the shops, and I encountered an error.

What happens is that when players are in their inventory they are unable to move items around because of this skript. Does anyone know how to fix this?

Code:
command /buy:
    permission: buy.buy
    trigger:
        set {buy} to chest inventory with 5 rows named "&3&lRanks"
        set slot 0 of {buy} to white stained glass pane named " "
        set slot 1 of {buy} to white stained glass pane named " "
        set slot 2 of {buy} to white stained glass pane named " "
        set slot 3 of {buy} to white stained glass pane named " "
        set slot 4 of {buy} to white stained glass pane named " "
        set slot 5 of {buy} to white stained glass pane named " "
        set slot 6 of {buy} to white stained glass pane named " "
        set slot 7 of {buy} to white stained glass pane named " "
        set slot 8 of {buy} to white stained glass pane named " "
        set slot 9 of {buy} to white stained glass pane named " "
        set slot 10 of {buy} to lime concrete named "&a&lVIP Rank" with lore "&aClick for link in chat"
        set slot 11 of {buy} to light blue concrete named "&b&lMVP Rank" with lore "&aClick for link in chat"
        set slot 12 of {buy} to blue concrete named "&9&lTHOR Rank" with lore "&aClick for link in chat"
        set slot 17 of {buy} to white stained glass pane named " "
        set slot 18 of {buy} to white stained glass pane named " "
        set slot 26 of {buy} to white stained glass pane named " "
        set slot 27 of {buy} to white stained glass pane named " "
        set slot 35 of {buy} to white stained glass pane named " "
        set slot 36 of {buy} to white stained glass pane named " "
        set slot 37 of {buy} to white stained glass pane named " "
        set slot 38 of {buy} to white stained glass pane named " "
        set slot 39 of {buy} to white stained glass pane named " "
        set slot 40 of {buy} to white stained glass pane named " "
        set slot 41 of {buy} to white stained glass pane named " "
        set slot 42 of {buy} to white stained glass pane named " "
        set slot 43 of {buy} to white stained glass pane named " "
        set slot 44 of {buy} to white stained glass pane named " "
        open {buy} to player

on inventory click:
    if clicked slot in is 0:
        cancel event
    if clicked slot is 1:
        cancel event
    if clicked slot is 2:
        cancel event
    if clicked slot is 3:
        cancel event
    if clicked slot is 4:
        cancel event
    if clicked slot is 5:
        cancel event
    if clicked slot is 6:
        cancel event
    if clicked slot is 7:
        cancel event
    if clicked slot is 8:
        cancel event
    if clicked slot is 9:
        cancel event
    if clicked slot is 17:
        cancel event
    if clicked slot is 18:
        cancel event
    if clicked slot is 26:
        cancel event
    if clicked slot is 27:
        cancel event
    if clicked slot is 35:
        cancel event
    if clicked slot is 36:
        cancel event
    if clicked slot is 37:
        cancel event
    if clicked slot is 38:
        cancel event
    if clicked slot is 39:
        cancel event
    if clicked slot is 40:
        cancel event
    if clicked slot is 41:
        cancel event
    if clicked slot is 42:
        cancel event
    if clicked slot is 43:
        cancel event
    if clicked slot is 44:
        cancel event
 
I am trying to Skript a /buy command so my players can easily access the shops, and I encountered an error.

What happens is that when players are in their inventory they are unable to move items around because of this skript. Does anyone know how to fix this?

Code:
command /buy:
    permission: buy.buy
    trigger:
        set {buy} to chest inventory with 5 rows named "&3&lRanks"
        set slot 0 of {buy} to white stained glass pane named " "
        set slot 1 of {buy} to white stained glass pane named " "
        set slot 2 of {buy} to white stained glass pane named " "
        set slot 3 of {buy} to white stained glass pane named " "
        set slot 4 of {buy} to white stained glass pane named " "
        set slot 5 of {buy} to white stained glass pane named " "
        set slot 6 of {buy} to white stained glass pane named " "
        set slot 7 of {buy} to white stained glass pane named " "
        set slot 8 of {buy} to white stained glass pane named " "
        set slot 9 of {buy} to white stained glass pane named " "
        set slot 10 of {buy} to lime concrete named "&a&lVIP Rank" with lore "&aClick for link in chat"
        set slot 11 of {buy} to light blue concrete named "&b&lMVP Rank" with lore "&aClick for link in chat"
        set slot 12 of {buy} to blue concrete named "&9&lTHOR Rank" with lore "&aClick for link in chat"
        set slot 17 of {buy} to white stained glass pane named " "
        set slot 18 of {buy} to white stained glass pane named " "
        set slot 26 of {buy} to white stained glass pane named " "
        set slot 27 of {buy} to white stained glass pane named " "
        set slot 35 of {buy} to white stained glass pane named " "
        set slot 36 of {buy} to white stained glass pane named " "
        set slot 37 of {buy} to white stained glass pane named " "
        set slot 38 of {buy} to white stained glass pane named " "
        set slot 39 of {buy} to white stained glass pane named " "
        set slot 40 of {buy} to white stained glass pane named " "
        set slot 41 of {buy} to white stained glass pane named " "
        set slot 42 of {buy} to white stained glass pane named " "
        set slot 43 of {buy} to white stained glass pane named " "
        set slot 44 of {buy} to white stained glass pane named " "
        open {buy} to player

on inventory click:
    if clicked slot in is 0:
        cancel event
    if clicked slot is 1:
        cancel event
    if clicked slot is 2:
        cancel event
    if clicked slot is 3:
        cancel event
    if clicked slot is 4:
        cancel event
    if clicked slot is 5:
        cancel event
    if clicked slot is 6:
        cancel event
    if clicked slot is 7:
        cancel event
    if clicked slot is 8:
        cancel event
    if clicked slot is 9:
        cancel event
    if clicked slot is 17:
        cancel event
    if clicked slot is 18:
        cancel event
    if clicked slot is 26:
        cancel event
    if clicked slot is 27:
        cancel event
    if clicked slot is 35:
        cancel event
    if clicked slot is 36:
        cancel event
    if clicked slot is 37:
        cancel event
    if clicked slot is 38:
        cancel event
    if clicked slot is 39:
        cancel event
    if clicked slot is 40:
        cancel event
    if clicked slot is 41:
        cancel event
    if clicked slot is 42:
        cancel event
    if clicked slot is 43:
        cancel event
    if clicked slot is 44:
        cancel event
If you are going to do vanilla guis use MetaData Tags.

Also, you've a lot of unnecessary code. You should reduce it.
code_language.skript:
command /buy:
   permission: buy.buy
   trigger:
        set metadata tag "BuyInvMeta" of player to chest inventory with 5 rows named "&3&lRanks"
        loop numbers between 0 and 44:
           set slot loop-number of metadata tag "BuyInvMeta" of player to white stained glass pane named ""
        set slot 10 of metadata tag "BuyInvMeta" of player to lime concrete named "&a&lVIP Rank" with lore "&aClick for link in chat"
        set slot 11 of metadata tag "BuyInvMeta" of player to light blue concrete named "&b&lMVP Rank" with lore "&aClick for link in chat"
        set slot 12 of metadata tag "BuyInvMeta" of player to blue concrete named "&9&lTHOR Rank" with lore "&aClick for link in chat"
        #set slot %number% of metadata tag "BuyInvMeta" of player to %item% named "Name" with lore "lore" #If you want to add more.
        wait a tick
        open (metadata tag "BuyInvMeta" of player) to player
#Then to the effects:
on inventory click:
    event-inventory = (metadata tag "BuyInvMeta" of player):
        cancel event #Make the items unsteleable
        index of event-slot = 10:
            #do stuff when click vip slot
        index of event-slot = 11:
            #do stuff when click mvp slot
        index of event-slot = 12:
            #do stuff when click thor slot
 
Thank you very much, I will try this
[doublepost=1614640556,1614639981][/doublepost]Got 16 indentation errors, but i think i can fix that on my own
 
Thank you very much, I will try this
[doublepost=1614640556,1614639981][/doublepost]Got 16 indentation errors, but i think i can fix that on my own
I recommend you don't copy and paste the direct code of the post. Write it word for word to avoid Space/Tab errors. Also, if you can send a screen of the error
 
Even when copied directly into word i still get the same errors (written down word for word, indent for indent

upload_2021-3-1_15-55-0.png

upload_2021-3-1_15-55-27.png

upload_2021-3-1_15-55-50.png

[doublepost=1614647703,1614642955][/doublepost]
If you are going to do vanilla guis use MetaData Tags.

Also, you've a lot of unnecessary code. You should reduce it.
code_language.skript:
command /buy:
   permission: buy.buy
   trigger:
        set metadata tag "BuyInvMeta" of player to chest inventory with 5 rows named "&3&lRanks"
        loop numbers between 0 and 44:
           set slot loop-number of metadata tag "BuyInvMeta" of player to white stained glass pane named ""
        set slot 10 of metadata tag "BuyInvMeta" of player to lime concrete named "&a&lVIP Rank" with lore "&aClick for link in chat"
        set slot 11 of metadata tag "BuyInvMeta" of player to light blue concrete named "&b&lMVP Rank" with lore "&aClick for link in chat"
        set slot 12 of metadata tag "BuyInvMeta" of player to blue concrete named "&9&lTHOR Rank" with lore "&aClick for link in chat"
        #set slot %number% of metadata tag "BuyInvMeta" of player to %item% named "Name" with lore "lore" #If you want to add more.
        wait a tick
        open (metadata tag "BuyInvMeta" of player) to player
#Then to the effects:
on inventory click:
    event-inventory = (metadata tag "BuyInvMeta" of player):
        cancel event #Make the items unsteleable
        index of event-slot = 10:
            #do stuff when click vip slot
        index of event-slot = 11:
            #do stuff when click mvp slot
        index of event-slot = 12:
            #do stuff when click thor slot

I noticed in this post you said "vanilla guis." I have Skript, SkQuery, ans Tuske installed. I remember hearing something about Tuske GUI's, but I don't know how to make them. Would it be more efficient to use Tuske as opposed to vanilla GUI's?
 
Even when copied directly into word i still get the same errors (written down word for word, indent for indent

View attachment 5817
View attachment 5818
View attachment 5819
[doublepost=1614647703,1614642955][/doublepost]

I noticed in this post you said "vanilla guis." I have Skript, SkQuery, ans Tuske installed. I remember hearing something about Tuske GUI's, but I don't know how to make them. Would it be more efficient to use Tuske as opposed to vanilla GUI's?
Well... in skript dev36 (minecraft 1.8) I would recommend using TuSKe inventories, from higher versions (Or at least 1.16) I would recommend using vanilla inventories.

In terms of efficiency, the Vanilla and TuSKe inventories are better in my opinion. SkQuery has some bugs that prevent the correct execution of the script.

Now, continuing with the error, you may have been passed a ':' possibly in the trigger line. If this is not the case, send the code you have to see what error there is.
 
Looking back, i did not miss a colon on the trigger line, but here is the code that I copied into word:


Code:
Command /buy:
    Permission: buy.buy
    Trigger:
        Set metadata tag “BuyInvMeta of player to chest inventory with 5 rows named “&3&lRanks”
        Loop numbers between 0 and 44:
            Set slot loop-number of metadata tag “BuyInvMeta” of player with white stained glass pane named “ “
        Set slot 10 of metadata tag “BuyInvMeta” of player to lime concrete named “&a&lVIP Rank” with lore “&aClick for link in chat”
        Set slot 11 of metadata tag “BuyInvMeta” of player to lime concrete named “&b&lMVP Rank” with lore “&aClick for link in chat”
        Set slot 12 of metadata tag “BuyInvMeta” of player to lime concrete named “&9&lTHOR Rank” with lore “&aClick for link in chat”
        Set slot 13 of metadata tag “BuyInvMeta” of player to lime concrete named “&3&lGOD Rank” with lore “&aClick for link in chat”
        Wait a tick
        Open (metadata tag “BuyInvMeta” of player) to player

On inventory click:
    Event-inventory = (metadata tag “BuyInvMeta of player):
        Cancel event
        Index of event-slot = 10:
            message "&aLink to VIP Rank:"
            message "&9https://shoppy.gg/product/Ksd2POP"
        index of event-slot = 11:
            message "&aLink to MVP Rank:"
            message "&9https://shoppy.gg/product/yqs3bIh"
        index of event-slot = 12:
            message "&aLink to THOR Rank:"
            message "&9https://shoppy.gg/product/wh9oAIb"
        index of event-slot = 13:
            message "&aLink to GOD Rank:"
            message "&9https://shoppy.gg/product/WeYmW68"
 
Looking back, i did not miss a colon on the trigger line, but here is the code that I copied into word:


Code:
Command /buy:
    Permission: buy.buy
    Trigger:
        Set metadata tag “BuyInvMeta of player to chest inventory with 5 rows named “&3&lRanks”
        Loop numbers between 0 and 44:
            Set slot loop-number of metadata tag “BuyInvMeta” of player with white stained glass pane named “ “
        Set slot 10 of metadata tag “BuyInvMeta” of player to lime concrete named “&a&lVIP Rank” with lore “&aClick for link in chat”
        Set slot 11 of metadata tag “BuyInvMeta” of player to lime concrete named “&b&lMVP Rank” with lore “&aClick for link in chat”
        Set slot 12 of metadata tag “BuyInvMeta” of player to lime concrete named “&9&lTHOR Rank” with lore “&aClick for link in chat”
        Set slot 13 of metadata tag “BuyInvMeta” of player to lime concrete named “&3&lGOD Rank” with lore “&aClick for link in chat”
        Wait a tick
        Open (metadata tag “BuyInvMeta” of player) to player

On inventory click:
    Event-inventory = (metadata tag “BuyInvMeta of player):
        Cancel event
        Index of event-slot = 10:
            message "&aLink to VIP Rank:"
            message "&9https://shoppy.gg/product/Ksd2POP"
        index of event-slot = 11:
            message "&aLink to MVP Rank:"
            message "&9https://shoppy.gg/product/yqs3bIh"
        index of event-slot = 12:
            message "&aLink to THOR Rank:"
            message "&9https://shoppy.gg/product/wh9oAIb"
        index of event-slot = 13:
            message "&aLink to GOD Rank:"
            message "&9https://shoppy.gg/product/WeYmW68"
Are you using Tab Key or Space Key?
 
Also, there is a syntax error inside the loop. Change this:
code_language.skript:
Set slot loop-number of metadata tag “BuyInvMeta” of player with white stained glass pane named “ “

to this:

code_language.skript:
Set slot loop-number of metadata tag "BuyInvMeta" of player to white stained glass pane named " "
[doublepost=1614719164,1614719085][/doublepost]
Using tab. Should i be using the space key?
From what I read in the errors, you are using Tabs and spaces within the same script. That may be one of the causes of those errors.
 
Status
Not open for further replies.