So I created a queuing system where a player can join a queue and once the queue is full, or 30 seconds has passed in the queue, the game will start and the list of players in the queue will be transferred over into a number and an arena will be set. And the way I'm checking the amount of players left in game is with my {game1} variable. Each {game} variable correspond with {arena} variable. {arena2} = {arena2} and so on..
I know it's alot of code to read through but I'm in desperate need of making this more compact and optimal because I do not want to be repeating code.
code_language.skript:
command /queue [<text="check">]:
usage: You can either use &c/queue join &for &c/queue leave
trigger:
if arg-1 is "check":
send "&cThere are &e%{queue}%/16 &cplayers in the queue!" to player
if arg-1 is "join":
if {game1::%player%} or {game2::%player%} or {game3::%player%} or {game4::%player%} or {game5::%player%} is 0:
if {arena1} or {arena2} or {arena3} or {arena4} or {arena5} is 0:
if {queue} >= 16:
send "&cThe queue is full!" to player
else:
if "%{players::*}%" contains "%player%":
send "&cYou are already in the queue!" to player
else:
add "%player%" to {players::*}
set {queue} to size of {players::*}
send "&a%player% &chas joined the queue! &a(%{queue}%/16)" to all players in world "world2"
else:
send "&cThere are no available arenas!" to player
else:
send "&cYou are already in a game!" to player
if arg-1 is "start":
if executor is console:
if {queue} >= 1:
if {arena1} and {arena2} and {arena3} and {arena4} and {arena5} is 1:
broadcast "&cAll arenas are full!"
else:
load world "Wasteland"
send "&3The match will begin in 30 seconds!" to all players in world "world2"
send "&3Teleporting players..." to all players in world "world2"
if {arena1} is 0:
set {game1} to {queue}
delete {queue}
set {arena1} to 1
send "&aPlayers can now join the queue for the next game." to all players in world "world2"
execute console command "/starttimer"
loop {players::*}:
clear loop-value parsed as player's inventory
set {_loc} to random element out of {loc1::*}
set {_loop-player} to loop-value parsed as player
teleport {_loop-player} to {_loc}
execute console command "givepython %loop-value parsed as player%"
give {_loop-player} 64 steak
set {game1::%{_loop-player}%} to 1
wait 2 seconds
delete {players::*}
I know it's alot of code to read through but I'm in desperate need of making this more compact and optimal because I do not want to be repeating code.