options:
#This is the name of the crate
name: "&6Crates System"
on rightclick on jukebox:
cancel event
open chest with 3 rows named {@name} to player
#Add your items below
#If you want to adjust the percent of an item. Add more of the other items.
#So if you want to make beacons rare. Add every item except beacon again. This raises the chance to get a different item than beacon.
add stone, diamond, diamond sword, gold block, redstone, redstone block, beacon, name tag, emerald and gravel to {_roll::*}
add dirt named "&6DIRT" to {_roll::*}
#Speed option safety net, so running 0 ticks doesn't crash your server.
#This is basically how fast the rolling starts (Should be higher than 0)
set {_speedFinal} to 2
#Selector settings (Where the selectors should be)
set {_Selector1} to 4
set {_Selector2} to 22
#Main code below. This random integer is the time length of the crate opening, which is random.
loop (random integer between 21 and 50) times:
#If they close their inventory stop the system
if inventory name of player's current inventory is not {@name}:
stop
#The {_sel} tells the script how many item slots there are, in order to save them.
set {_sel} to 21
loop {_sel} times:
#This is the data saving for the scroll effect
set {_sel2} to {_sel} - 1
set {_item::%{_sel}%} to {_item::%{_sel2}%}
subtract 1 from {_sel}
#Grab a new item from the options
set {_item::1} to a random element out of {_roll::*}
#This below just updates the GUI
loop integers between 0 and inventory size of player's current inventory - 1:
if loop-number-2 is {_Selector1} or {_Selector2}:
set slot loop-number-2 of player's current inventory to shiny light green stained glass pane named " "
else:
set slot loop-number-2 of player's current inventory to black stained glass pane named " "
loop 9 times:
set slot 8 + loop-number-3 of player's current inventory to {_item::%loop-number-3%}
#This below is just sound. It plays it for the player.
add 1 to {_sound}
if {_sound} > 3:
set {_sound} to 1
if {_sound} = 1:
play BLOCK_NOTE_PLING for player with volume 1 and pitch 4
else if {_sound} = 2:
play BLOCK_NOTE_PLING for player with volume 1 and pitch 3
else if {_sound} = 3:
play BLOCK_NOTE_PLING for player with volume 1 and pitch 1
add 1 to {_speed}
#This below causes the crate to slow down when it gets closer to the end of the animation. The greater the {_speed} test, the longer the tick delay will be.
#Meaning it will slow down more of the speed every X number of updates.
if {_speed} is 5:
set {_speed} to 0
add 1 to {_speedFinal}
loop {_speedFinal} times:
wait a tick
#This is where you can give players or test for which item has won and give stuff based on that item.
set {_wonItem} to slot 13 of player's current inventory
message "You won %{_wonItem}%"
give player {_wonItem}
#This is just a system so that they can't steal any of the items
on inventory click:
if inventory name of player's current inventory is {@name}:
cancel event