Items not displaying in 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!

wxspanda

Member
Jan 6, 2025
1
0
1
24
options:
shop-title: "Shard Store"
max-rows: 6 # Max number of rows in the shop GUI

on join:
if {shards::%player's uuid%} is not set:
set {shards::%player's uuid%} to 0

on death of player:
if attacker is a player:
set {_uuid} to uuid of attacker
add 10 to {shards::%{_uuid}%}
send action bar "&7You gained &a10 &5shards!" to attacker

command /storeadmin add <number> <number>:
permission: store.admin
trigger:
if held item is air:
send "&cYou must hold an item to add it to the store!" to player
stop

set {store::%arg-1%::item} to held item
set {store::%arg-1%::row} to arg-1
set {store::%arg-1%::emoji_stuck_out_tongue:rice} to arg-2

set {store::%arg-1%::name} to name of held item # Save the item name

send "&aAdded &7%held item%&a to the store for &e%arg-2%&7 shards at row &e%arg-1%" to player


command /store:
trigger:
set {_gui} to a new chest inventory with 6 rows named "Shard Store"

set {_slots::*} to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53


loop {_slots::*}:
set {_slotData} to {store::%loop-value%}
if {_slotData} is set:
set {_item} to {_slotData::item}
set {_name} to {_slotData::name}
set {_price} to {_slotData::emoji_stuck_out_tongue:rice}

set slot {_loop-value} of {_gui} to {_item} with lore "Price: %{_price}% shards"
set slot {_loop-value} of {_gui} to {_item} named "&e%{_name}%"
else:
set slot {_loop-value} of {_gui} to air

open {_gui} to player


on inventory click:
if name of event-inventory is {@shop-title}:
cancel event

set {_clickedItem} to event-item
set {_clickedItemSlot} to index of event-slot


set {_itemname} to {store::%{_clickedItemSlot}%::name}
set {_price} to {store::%{_clickedItemSlot}%::emoji_stuck_out_tongue:rice}
set {_clickedItem} to {store::%{_clickedItemSlot}%::item}
set {_itemtype} to {store::%{_clickedItemSlot}%::type}

send "&aYou are buying: %{_itemname}% (ID: %{_itemtype}%) for %{_price}% shards!" to player

send "&aYou have &7%{shards::%player's uuid%}%&a shards!" to player # Show current shards
if {shards::%player's uuid%} >= {_price}:
remove {_price} from {shards::%player's uuid%}
give {_clickedItem} to player
send "&aYou bought &7%{_itemname}% (ID: %{_itemtype}%)&a for &e%{_price}%&7 shards!" to player
else:
send "&cYou don't have enough shards to buy this item!" to player

command /resetstore:
permission: store.admin
trigger:
delete {store::*}
send "&aAll store items have been reset!" to player