Code:
command /crates:
description: The laziest best way of doing something.
trigger:
open chest inventory with 4 rows named "&b&lCrates" to player
set slot 0 of player's current inventory to stone named "&b&lCustom Crate"
on inventory click:
#check if the clicked inventory is the one we just created
if name of event-inventory is "&b&lCrates":
#cancel the clicking. This makes the Item unstealable
cancel event
if index of event-slot is 0:
if event-click type is right mouse button:
set {_gui} to a new chest inventory with 2 row named "&a&lCustom Crate Rewards"
set slot 0 of {_gui} to 1 tripwire hook named "&a&lCustom Crate Key" with lore "&a&lThis reward gives ", " ", "1 Custom Crate Key ", " " and "With a Chance of: 15%%"
set slot 1 of {_gui} to 2 tripwire hook named "&a&lCustom Crate Key" with lore "&a&lThis reward gives ", " ", "2 Custom Crate Keys ", " " and "With a Chance of: 10%%"
set slot 2 of {_gui} to 3 tripwire hook named "&a&lCustom Crate Key" with lore "&a&lThis reward gives ", " ", "3 Custom Crate Keys ", " " and "With a Chance of: 5%%"
set slot 3 of {_gui} to 1 emerald named "&a&lMoney" with lore "&a&lThis reward gives ", " ", "$100k ", " " and "With a Chance of: 50%%"
set slot 4 of {_gui} to 1 emerald named "&a&lMoney" with lore "&a&lThis reward gives ", " ", "$150k ", " " and "With a Chance of: 25%%"
set slot 5 of {_gui} to 1 emerald named "&a&lMoney" with lore "&a&lThis reward gives ", " ", "$250k ", " " and "With a Chance of: 16%%"
set slot 6 of {_gui} to 1 emerald named "&a&lMoney" with lore "&a&lThis reward gives ", " ", "$500k ", " " and "With a Chance of: 8%%"
set slot 7 of {_gui} to 1 emerald named "&a&lMoney" with lore "&a&lThis reward gives ", " ", "$1M ", " " and "With a Chance of: 1%%"
set slot 8 of {_gui} to 1 red dye named "&4&lHea&c&lrt" with lore "&a&lThis reward gives ", " ", "1 Heart ", " " and "With a Chance of: 15%%"
set slot 9 of {_gui} to 2 red dye named "&4&lHea&c&lrt" with lore "&a&lThis reward gives ", " ", "2 Hearts ", " " and "With a Chance of: 5%%"
set slot 10 of {_gui} to 1 ghast tear named "&4&lHeart &c&lFragment" with lore "&a&lThis reward gives ", " ", "1 Heart Fragment", " " and "With a Chance of: 15%%"
set slot 11 of {_gui} to 3 ghast tear named "&4&lHeart &c&lFragment" with lore "&a&lThis reward gives ", " ", "3 Heart Fragments", " " and "With a Chance of: 5%%"
if player's inventory contains tripwire hook named "&a&lCustom Crate Key":
set {_chance} to a random integer from 1 to 50
# KEYS
if {_chance} is 1:
give player 1 tripwire hook named "&a&lCustom Crate Key"
if {_chance} is 2:
give player 2 tripwire hook named "&a&lCustom Crate Key"
if {_chance} is 3:
give player 3 tripwire hook named "&a&lCustom Crate Key"
# MONEY
if {_chance} is 4:
add 100000 to {economy::balance::%player%}
if {_chance} is 5:
add 150000 to {economy::balance::%player%}
if {_chance} is 6:
add 250000 to {economy::balance::%player%}
if {_chance} is 7:
add 500000 to {economy::balance::%player%}
if {_chance} is 8:
add 1000000 to {economy::balance::%player%}
# HEARTS
if {_chance} is 9:
give player 1 red dye named "&4&lHea&c&lrt"
if {_chance} is 10:
give player 2 red dye named "&4&lHea&c&lrt"
# HEART FRAGMENTS
if {_chance} is 11:
give player 1 ghast tear named "&4&lHeart &c&lFragment"
if {_chance} is 12:
give player 3 ghast tear named "&4&lHeart &c&lFragment"