Jump to content

Help me I got stuck making a shop skript for 1.21.1


V0listic

Recommended Posts

command /menu:
    trigger:
        set {_menu} to a new chest inventory with 3 row named "&6 Menu"
        set slot 13 of {_menu} to diamond named "&9Shop" # is the name of diamond item
        open {_menu} to player
       
 
on inventory click: # Listen for players clicking in an inventory.
    name of event-inventory is "&6 Menu"
    cancel event
    set {_menu} to a new chest inventory with 3 row named "&9Shop" # opens a new chest called shop
    set slot 13 of {_menu} to diamond named "&2Buy for $157"
    open {_menu} to player
 
on inventory click:
    name of event-inventory is "&9Shop"
    cancel event
    set {_menu} to a new chest inventory named "Buy"
    set slot integers from 0 to 26 of {_menu} to grey stained glass pane with name " "
    set slot 13 of {_menu} to diamond named "diamond" # is the name of diamond item
    set slot 12 of {_menu} to red stained glass pane named "&4-1"
    set slot 14 of {_menu} to green stained glass pane named "&2+1"
    set slot 22 of {_menu} to green dye named "&aConfirm"
    set slot 4 of {_menu} to red dye named "&cCancel"
    open {_menu} to player
 
on inventory click:
    name of event-inventory is "&aBuy"
    cancel event
    if index of event-slot is 4:
        close player's inventory
 
on inventory click:
    name of event-inventory is "&aBuy"
    cancel event
    if index of event-slot is 13:
Link to comment
Share on other sites

What are you stuck on? Also you should use metadata to make GUIs. Like this:

command /shop:
	trigger:
		set {_gui} to chest inventory with 3 rows named "Shop"
		set slot 0 of {_gui} with diamond named "Diamond: $50"
		set metadata tag "shop" of player to {_gui}
		open {_gui} to player

on inventory click:
	event-inventory is metadata tag "shop" of player
	cancel event
	if index of event-slot is 0:
		# remove money, give diamond

And if you want to make it even better, look into using functions to simplify the process and so you don't have to manually specify each item and its price and click action.

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 - 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - 12/20/22

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

why are you using so many spaces _tarna_ ? why not just do this

command shop:
 trigger:
  set {gui} to chest inventory with 3 rows named "Shop"
  set slot 0 of {gui} with diamond named "Diamond: $50"
  set metadata tag "shop" of player to {gui}
  open {gui} to player
on inventory click:
 event-inventory is metadata tag "shop" of player
 cancel event
 index of event-slot is 0:

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...