Code:
# #
# Options #
# #
options:
p: &8[&5Crates&8]&c
# #
# Opening #
# #
on rightclick on chest:
cancel event
if {crate::mystery} is location of block:
if player's held item is a book named "&5Mystery Key!":
remove 1 book named "&5Mystery Key!" from player's inventory
set {_tal} to random integer between 0 and 100
if {_tal} is between 0 and 40:
add 100000 to player's balance
send "{@p} You won &e100k &cwith the chance of &840%%"
if {_tal} is between 41 and 70:
add 150000 to player's balance
send "{@p} You won &e150k &cwith the chance of &830%%"
if {_tal} is between 71 and 90:
add 250000 to player's balance
send "{@p} You won &e250k &cwith the chance of &820%%"
if {_tal} is between 91 and 99:
add 500000 to player's balance
send "{@p} You won &e500k &cwith the chance of &89%%"
if {_tal} is between 99 and 100:
make console execute command "kit mystery %player%"
send "{@p} You won &5kit Mystery &cwith the chance of &81%%"
# #
# Crate + Keys #
# #
command /givecrate [<text>]:
permission: *
trigger:
if arg-1 is set:
if arg-1 is "mystery":
give player 1 chest named "&5Mystery Crate"
on place of chest:
if player has permission "*":
if player's tool is chest named "&5Mystery Crate":
set {crate::mystery} to location of block
send "{@p} You created a &5Mystery Crate&c!"
# #
# Preview #
# #
on leftclick on chest:
cancel event
if {crate::mystery} is location of block:
wait 1 tick
open virtual chest with 1 row named "&5Mystery Crate" to player
format slot 0 of player with paper named "&e100k" with lore "&740%% chance" to be unstealable
format slot 2 of player with paper named "&e150k" with lore "&730%% chance" to be unstealable
format slot 4 of player with paper named "&e250k" with lore "&720%% chance" to be unstealable
format slot 6 of player with paper named "&e500k" with lore "&79%% chance" to be unstealable
format slot 8 of player with book named "&5Kit Mystery!" with lore "&71%% chance" to be unstealable
format slot 1 of player with black stained glass pane named "&3" to be unstealable
format slot 3 of player with black stained glass pane named "&3" to be unstealable
format slot 5 of player with black stained glass pane named "&3" to be unstealable
format slot 7 of player with black stained glass pane named "&3" to be unstealable