This is my current code, in which for whatever reason the "cancel event" that should cancel inventory click isn't working. Am I missing something or is this a bug within skript?
Code:
function makeMenu(name: text, rows: number) :: inventory:
set {_gui} to a new chest inventory with {_rows} rows with name {_name}
set slot 1 of {_gui} to iron axe named "&1Pirate" with lore "&r&fWays to gain xp:%nl%&r&fKilling players%nl%&r&flooting (use /loot)%nl%&r&fswimming"
set slot 2 of {_gui} to diamond pickaxe named "&fMiner" with lore "&r&fWays to gain xp:%nl%&r&fMining"
set slot 3 of {_gui} to spyglass named "&6Adventurer" with lore "&r&fWays to gain xp:%nl%&r&fWalking"
set slot 4 of {_gui} to gold sword named "&8Warrior" with lore "&r&fWays to gain xp:%nl%&r&fKilling Monsters"
set slot 5 of {_gui} to carrot named "&aFarmer" with lore "&r&fWays to gain xp:%nl%&r&fHarvesting grown crops"
set slot 6 of {_gui} to oak log named "&6Builder" with lore "&r&fWays to gain xp:%nl%&r&fPlacing blocks"
return {_gui}
command /class choose:
trigger:
if {clss::%player%} is not set:
set {_menu} to makeMenu("Classes", 1)
open {_menu} to player
add {_menu} to {my inventories::*}
else if {clss::%player%} is "no class":
set {_menu} to makeMenu("Classes", 1)
add {_menu} to {my inventories::*} # Prepare to listen to this inventory.
open {_menu} to player
else:
send "&l&3[CaribbeanFun]&r: &4You have already chosen a class"
on inventory click: # Listen for players clicking in any inventory.
if {my inventories::*} contains event-inventory:
cancel event
index of event-slot is 1:
set {clss::%player%} to "Pirate"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
index of event-slot is 2:
set {clss::%player%} to "Miner"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
index of event-slot is 3:
set {clss::%player%} to "Adventurer"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
index of event-slot is 4:
set {clss::%player%} to "Warrior"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
index of event-slot is 5:
set {clss::%player%} to "Farmer"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
index of event-slot is 6:
set {clss::%player%} to "Builder"
send "&l&3[CaribbeanFun]&r: You have chosen %{clss::%player%}%"
close inventory of player
on inventory close: # No longer need to listen to this inventory.
{my inventories::*} contains event-inventory:
remove event-inventory from {my inventories::*}