Best way to refill chest in skywars?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

MeHow

Active Member
Feb 6, 2017
140
13
18
22
Lithuania
Hello guys! I am trying to do center chest refill and 1 island chest refill (every island have chance for 4 patterns)
My code:
code_language.skript:
        if arg-1 is "join":
            if arg-2 is set:
                set {arena.%player%} to arg-2
                if {sw.arena.%arg-2%.online} is true:
                    set {sw.%player%.ingame} to true
                    add 1 to {sw.arena.%arg-2%.list}
                    add player to {sw.arena.%arg-2%.players::*}
                    clear player's inventory
                    set slot 0 of player to iron door named "&c&oLeave"
                    set slot 8 of player to book named "&9&oKits"     
                    set player's gamemode to adventure
                    heal the player               
                    if {sw.%player%.cage} is not set:
                        set {sw.%player%.cage} to "dcage"                                   
                    loop {sw.arena.%arg-2%.players::*}:
                        paste schematic "%{sw.%player%.cage}%" at {skyw.cagespawn%loop-index%.%{arena.%loop-value%}%}
                        wait 4 ticks
                        teleport loop-value to {skyw.cagespawn%loop-index%.%{arena.%loop-value%}%}
                        wait 3 ticks
                    loop all blocks in radius 10 of player:               
                        set {_chestpatern.mid} to a random integer between 1 and 4
                        if {_chestpatern.mid} is 1:           
                            if loop-block is a chest:   
                                clear loop-block's inventory                   
                                clear {list.p1::*}
                                loop {chestitems.p1.::*}:
                                    add loop-value-2 to {list.p1::*}
                                wait 5 ticks
                                loop {list.p1::*}:
                                    set {_slot} to a random number between 1 and 27
                                    set slot {_slot} of loop-block to loop-value-2       
                                    remove loop-value-2 from {list.p1::*}       
                                                                
                        if {_chestpatern.mid} is 2:       
                            if loop-block is a chest:   
                                clear loop-block's inventory
                                clear {list.p2::*}
                                loop {chestitems.p2.::*}:
                                    add loop-value-2 to {list.p2::*}
                                wait 5 ticks
                                loop {list.p2::*}:
                                    set {_slot} to a random number between 1 and 27
                                    set slot {_slot} of loop-block to loop-value-2       
                                    remove loop-value-2 from {list.p2::*}   
                                                                    
                        if {_chestpatern.mid} is 3:           
                            if loop-block is a chest:   
                                clear loop-block's inventory                   
                                clear {list.p3::*}
                                loop {chestitems.p3.::*}:
                                    add loop-value-2 to {list.p3::*}                               
                                wait 5 ticks
                                    loop {list.p3::*}:
                                    set {_slot} to a random number between 1 and 27
                                    set slot {_slot} of loop-block to loop-value-2       
                                    remove loop-value-2 from {list.p3::*}       
                                                                
                        if {_chestpatern.mid} is 4:       
                            if loop-block is a chest:   
                                clear loop-block's inventory
                                clear {list.p4::*}
                                loop {chestitems.p4.::*}:
                                    add loop-value-2 to {list.p4::*}
                                wait 5 ticks
                                loop {list.p4::*}:
                                    set {_slot} to a random number between 1 and 27
                                    set slot {_slot} of loop-block to loop-value-2       
                                    remove loop-value-2 from {list.p4::*}
                                    
                    if {sw.arena.%arg-2%.list} > 1:
                        set {sw.arena.%arg-2%.starting} to true
                        clear {chestitems::*}
                        send "{@prefix} %arg-2% will start in 15 seconds" to {sw.arena.%arg-2%.players::*}
                        set {sw.arena.%arg-2%.players::*}'s level to 15
                        wait a second
                        set {sw.arena.%arg-2%.players::*}'s level to 14
                        wait a second
                        set {sw.arena.%arg-2%.players::*}'s level to 13
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 12
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 11
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 10
                        play sound "ENTITY_EXPERIENCE_ORB_PICKUP" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2                       
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 9
                        
                        loop all blocks in radius 30 of {sw.arena.%arg-2%.center}:               
                            set {_chestpatern.mid} to a random integer between 1 and 2
                            if {_chestpatern.mid} is 1:           
                                if loop-block is a chest:   
                                    clear loop-block's inventory                   
                                    clear {list.p5::*}
                                    loop {chestitems.p5.::*}:
                                        add loop-value-2 to {list.p5::*}
                                    wait 5 ticks
                                    loop {list.p5::*}:
                                        set {_slot} to a random number between 1 and 27
                                        set slot {_slot} of loop-block to loop-value-2       
                                        remove loop-value-2 from {list.p5::*}       
                                                                    
                            if {_chestpatern.mid} is 2:       
                                if loop-block is a chest:   
                                    clear loop-block's inventory
                                    clear {list.p6::*}
                                    loop {chestitems.p6.::*}:
                                        add loop-value-2 to {list.p6::*}
                                    wait 5 ticks
                                    loop {list.p6::*}:
                                        set {_slot} to a random number between 1 and 27
                                        set slot {_slot} of loop-block to loop-value-2                                           
                                        remove loop-value-2 from {list.p6::*}   
                                        
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 8
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 7
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 6
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 5
                        play sound "ENTITY_EXPERIENCE_ORB_PICKUP" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2                           
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 4
                        play sound "UI_BUTTON_CLICK" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2                           
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 3
                        play sound "UI_BUTTON_CLICK" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2                           
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 2
                        play sound "UI_BUTTON_CLICK" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2                           
                        wait a second   
                        set {sw.arena.%arg-2%.players::*}'s level to 1
                        play sound "UI_BUTTON_CLICK" to {sw.arena.%arg-2%.players::*} with volume 1 and pitch 2   
                        wait 3 ticks
                        set {sw.arena.%arg-2%.players::*}'s level to 0

How can I get this code for work?

Skript: 2.2
Mc: 1.8

Thanks <3
 
Status
Not open for further replies.