yes but I just have to add direction support for that part
[doublepost=1526063427,1526051307][/doublepost]Okay
@FabricioSouza I finished it for dev23 and it required SkQuery, Biosphere2, Skellett and Umbaska:
code_language.skript:
options:
skull-owner: MHF_Question
skull-owner-2: MHF_Exclamation
function animation(loct: location, p: player):
set {_b} to block above block at {_loct}
set {_f} to facing of block above block at {_loct}
if {_f} is north:
set {_angle} to 3.1
set {_d} to "z"
else if {_f} is east:
set {_angle} to 4.75
set {_d} to "x"
else if {_f} is south:
set {_d} to "z"
set {_angle} to 0
else if {_f} is west:
set {_d} to "x"
set {_angle} to 1.55
evaluate "openChest({_b}, 7.5 seconds)"
set {_loct2} to {_loct}
add 0.5 to y coord of {_loct2}
loop 6 times:
spawn armor stand at location of block at {_loct}
set {_as} to last spawned armor stand
add {_as} to {_as::*}
set visible of {_as} to false
set small of {_as} to true
set gravity of {_as} to false
set helmet of {_as} to skull of "{@skull-owner}" parsed as a offline player
set {_asloc} to location of {_as}
set y coord of {_asloc} to y coord of {_as} + 5
teleport {_as} to {_asloc}
loop 5 times:
add 1/6 to y coord of {_asloc}
teleport {_as} to {_asloc}
wait 1 tick
set y coord of {_asloc} to y coord of {_loct} + 1.5
teleport {_as} to {_asloc}
circleAS({_as}, {_asloc}, {_b}, {_loct2}, {_angle}, {_d})
wait 2 seconds
set {_l} to size of {_as::*}
delete {_as::%{_l}%}
set {_l::*} to {_as::*}
loop {_l::*}:
set {_o} to random element out of {_as::*}
remove {_o} from {_as::*}
kill {_o}
wait 4 ticks
set metadata "stop" of {_as} to true
while metadata "stopped" of {_as} is not set:
wait 1 tick
set {_asloc} to location of {_as}
loop 3 times:
remove 0.1 from y coord of {_asloc}
teleport {_as} to {_asloc}
wait 3 ticks
wait 2 ticks
set custom name visible of {_as} to true
set custom name of {_as} to "&kabcdefghijklmnop"
wait 1.5 seconds
show mob spawner flames at location of block above {_as} to all players
set helmet of {_as} to skull of "{@skull-owner-2}" parsed as a offline player
set custom name of {_as} to "&cYour price!"
# price code
give {_p} 1 diamond
send "&aYou got &ba diamond &afrom a crate!" to {_p}
# price code
wait 2 seconds
kill {_as}
function openChest(b: block, t: timespan):
set {_now} to now
while {_now} was less than {_t} ago:
skellett make {_b} look open for all players
wait 1 tick
function circleAS(as: entity, asloc: location, b: block, loct: location, angle: number, d: text):
set {_l::*} to circle at location of {_b} with radius 1 and density 5
loop {_l::*}:
set {_loc2} to loop-value
if {_d} is "z":
set z coord of {_loc2} to z coord of {_loct}
set y coord of {_loc2} to y coord of {_loct} - (z coord of {_loct} - z coord of loop-value)
set z coord of {_loc2} to z coord of {_loct}
else:
set x coord of {_loc2} to x coord of {_loct}
set y coord of {_loc2} to y coord of {_loct} - (x coord of {_loct} - x coord of loop-value)
set x coord of {_loc2} to x coord of {_loct}
set {_l::%loop-index%} to {_loc2}
loop {_l::*}:
set {_i} to loop-index parsed as a number + 24
if {_i} > size of {_l::*}:
remove size of {_l::*} from {_i}
set {_l2::%{_i}%} to loop-value
while true:
loop {_l2::*}:
teleport {_as} to loop-value
set head y angle of {_as} to {_angle}
wait 1 tick
teleport {_as} to {_asloc}
if metadata "stop" of {_as} is true:
wait 10 ticks
set metadata "stopped" of {_as} to true
stop
on right click on ender chest:
cancel event
set {_loc} to location of clicked block
remove 1.5 from y coord of {_loc}
animation({_loc}, player)
If you find any bugs tell me and I'll fix them
Here is a video I've made from the script, so this is what it should look like:
[doublepost=1526116894][/doublepost]
@Runakai1 I made it for the newest version (
dev35b) and it requires SkQuery and Skellett
Code:
code_language.skript:
options:
items-gui-name: &aCrate Items
crate-gui-name: &aCSGO Crate
command /csgoitems [<text>]:
permission: admin
trigger:
set {_s::*} to split arg-1 at " "
if {_s::1} is "list":
loop {csgocrate::items::*}:
set {_t} to "%loop-value%"
add 1 to {_items::%{_t}%}
if {_items::*} is not set:
message "&cNo items defined!"
stop
set {_rows} to rounded up (size of {_items::*} / 9)
open chest with {_rows} rows named "{@items-gui-name}" to player
set {_i} to 0
loop {_items::*}:
set slot {_i} of player's current inventory to loop-index parsed as a item named "&a%firstCapital(loop-index)%" with lore "&7Chance: %loop-value%"
add 1 to {_i}
stop
if {_s::1} is "add":
if {_s::2} is not set:
message "&cPlease input a second argument! Usage: /csgoitems add <chance> (your held item will be the item)"
stop
if {_s::2} parsed as a number is not set:
message "&cThe second argument has to be a number! Usage: /csgoitems add <chance> (your held item will be the item)"
stop
set {_c} to {_s::2} parsed as a number
if {_c} <= 0:
message "&cYour number must be positive and can't be 0! Usage: /csgoitems add <chance> (your held item will be the item)"
stop
if "%{_c}%" contains ".":
message "&cYour number must be a full number (1, 4, 8, 3) Usage: /csgoitems add <chance> (your held item will be the item)"
stop
if tool of player is air:
message "&cYou can't add air to the list! Usage: /csgoitems add <chance> (your held item will be the item)"
stop
loop {_c} times:
add tool of player to {csgocrate::items::*}
message "&a%firstCapital(tool of player)% added to the list with chance %{_c}%!"
stop
if {_s::1} is "remove":
if {_s::2} is not set:
message "&cPlease input a second argument! Usage: /csgoitems remove <item>"
stop
delete {_s::1}
set {_item} to join {_s::*} with " "
if {_item} parsed as a item is not set:
message "&cThe second argument has to be a item! Usage: /csgoitems remove <item>"
stop
remove every {_item} parsed as a item from {csgocrate::items::*}
message "&a%firstCapital({_item})% removed from the list!"
on inventory click:
name of player's current inventory is "{@items-gui-name}" or "{@crate-gui-name}"
cancel event
function firstCapital(t: object) :: string:
set {_l::*} to split "%{_t}%" at ""
set {_l::1} to {_l::1} in upper case
return join {_l::*} with ""
on join:
delete {csgocrate::opening::%player%}
on disconnect:
delete {csgocrate::opening::%player%}
function openCSGOCrate(p: player, new: boolean):
if {_new} is true:
set {csgocrate::opening::%{_p}%} to true
open chest with 3 rows named "{@crate-gui-name}" to {_p}
loop 2 times:
loop 3 times:
set slot ((loop-number-2) - 1) * 9 + ((loop-number-1) - 1) * 8 of {_p}'s current inventory to black glass named ""
loop 2 times:
loop 2 times:
loop 3 times:
set slot (((loop-number-3) + ((loop-number-2) - 1) * 18) + ((loop-number-1) - 1) * 4) of {_p}'s current inventory to red glass named ""
loop 2 times:
set slot ((loop-number - 1) * 18) + 4 of {_p}'s current inventory to torch named ""
if {_new} is false:
stop
loop 100 times:
add random element of {csgocrate::items::*} to {_items::*}
loop 10 times:
add 0.15 seconds to {_times::*}
loop 10 times:
add "%loop-number/20+0.15% seconds" parsed as a timespan to {_times::*}
set {_l::*} to {_items::*}
loop {_times::*}:
set {_l::*} to cycleList({_l::*})
if name of {_p}'s current inventory is "{@crate-gui-name}":
play sound "ENTITY_EXPERIENCE_ORB_PICKUP" to {_p} with volume 1 and pitch 3
set {_i} to 0
loop 7 times:
set slot loop-number + 9 of {_p}'s current inventory to {_l::%loop-number%}
wait loop-value
if {_new}:
delete {csgocrate::opening::%{_p}%}
set {_f} to {_l::4}
play sound "ENTITY_FIREWORK_BLAST" to {_p} with volume 1 and pitch 1
loop 3 times:
show mob spawner flames at {_p} to all players
give {_f} to {_p}
send "&aYou got &e%{_f}% &afrom a CSGO crate!" to {_p}
function cycleList(l: objects) :: objects:
loop {_l::*}:
set {_i} to loop-index parsed as a number + 1
set {_out::%{_i}%} to loop-value
set {_s} to size of {_out::*} + 1
set {_out::1} to {_out::%{_s}%}
delete {_out::%{_s}%}
return {_out::*}
on right click:
tool of player is player head
if {csgocrate::opening::%player%} is set:
openCSGOCrate(player, false)
stop
if {csgocrate::items::*} is not set:
message "&cNo items defined!"
stop
remove 1 player head from tool of player
openCSGOCrate(player, true)
Video:
(It has sound effects but my recording software didn't add it)
Also if you find any bugs please tell me and I'll try my best to fix them