Files
arenas.sk
commands.sk
config.sk
events.sk
gui.sk
invites.sk
matches.sk
rooms.sk
Code
8 768
rooms.sk
# BurnoutCS room storage and room management functions.
function cs_room_of(p: player) :: text:
if {burnoutcs.player-room::%uuid of {_p}%} is set:
return {burnoutcs.player-room::%uuid of {_p}%}
return ""
function cs_lobby() :: location:
return location at {@lobby-x}, {@lobby-y}, {@lobby-z} in world "{@lobby-world}"
function cs_room_exists(room: text) :: boolean:
if {burnoutcs.room.%{_room}%::owner} is set:
return true
return false
function cs_room_message(room: text, message: text):
loop {burnoutcs.room.%{_room}%::members::*}:
if loop-value is online:
send "{@prefix}%{_message}%" to loop-value
function cs_create_room(p: player):
if cs_room_of({_p}) is not "":
send "{@message-already-room}" to {_p}
stop
set {_room} to "%uuid of {_p}%"
add {_room} to {burnoutcs.rooms::*}
set {burnoutcs.room.%{_room}%::owner} to {_p}
set {burnoutcs.room.%{_room}%::status} to "lobby"
add {_p} to {burnoutcs.room.%{_room}%::members::*}
set {burnoutcs.player-room::%uuid of {_p}%} to {_room}
send "{@prefix}{@message-room-created}" to {_p}
send "{@prefix}&7Use &b/cs invite <player> &7to invite players." to {_p}
send "{@prefix}&7Use &b/cs arena &7to select an arena." to {_p}
function cs_teleport_room_to_lobby(room: text):
loop {burnoutcs.room.%{_room}%::members::*}:
if loop-value is online:
set gamemode of loop-value to survival
teleport loop-value to cs_lobby()
function cs_close_room(room: text):
if cs_room_exists({_room}) is false:
stop
set {_arena} to {burnoutcs.room.%{_room}%::arena}
if {_arena} is set:
cs_reset_arena({_arena})
delete {burnoutcs.arena.%{_arena}%::locked}
cs_teleport_room_to_lobby({_room})
loop {burnoutcs.room.%{_room}%::members::*}:
delete {burnoutcs.player-room::%uuid of loop-value%}
remove {_room} from {burnoutcs.rooms::*}
delete {burnoutcs.room.%{_room}%::*}
delete {burnoutcs.match.%{_room}%::*}
function cs_cancel_countdown(room: text):
if {burnoutcs.room.%{_room}%::status} is not "countdown":
stop
set {burnoutcs.room.%{_room}%::status} to "lobby"
set {_arena} to {burnoutcs.room.%{_room}%::arena}
if {_arena} is set:
delete {burnoutcs.arena.%{_arena}%::locked}
cs_room_message({_room}, "{@message-match-cancelled}")
function cs_leave_room(p: player):
set {_room} to cs_room_of({_p})
if {_room} is "":
send "{@message-not-room}" to {_p}
stop
set {_status} to {burnoutcs.room.%{_room}%::status}
remove {_p} from {burnoutcs.room.%{_room}%::members::*}
remove {_p} from {burnoutcs.match.%{_room}%::alive::*}
delete {burnoutcs.player-room::%uuid of {_p}%}
set gamemode of {_p} to survival
teleport {_p} to cs_lobby()
if {_status} is "countdown":
if size of {burnoutcs.room.%{_room}%::members::*} < 2:
cs_cancel_countdown({_room})
if {_status} is "running":
wait 1 tick
cs_check_winner({_room})
if size of {burnoutcs.room.%{_room}%::members::*} is 0:
cs_close_room({_room})
stop
if {_p} is {burnoutcs.room.%{_room}%::owner}:
set {_new-owner} to first element of {burnoutcs.room.%{_room}%::members::*}
set {burnoutcs.room.%{_room}%::owner} to {_new-owner}
cs_room_message({_room}, "&eThe previous owner left. &b%{_new-owner}% &eis now the room owner.")
else:
cs_room_message({_room}, "&e%{_p}% left the Custom Server.")
function cs_kick_player(owner: player, target: player):
set {_room} to cs_room_of({_owner})
if {_room} is "":
send "{@message-not-room}" to {_owner}
stop
if {burnoutcs.room.%{_room}%::owner} is not {_owner}:
send "{@message-owner-only}" to {_owner}
stop
if {burnoutcs.room.%{_room}%::status} is "running":
send "{@message-room-running}" to {_owner}
stop
if {_target} is not in {burnoutcs.room.%{_room}%::members::*}:
send "&cThat player is not in your room." to {_owner}
stop
remove {_target} from {burnoutcs.room.%{_room}%::members::*}
delete {burnoutcs.player-room::%uuid of {_target}%}
set gamemode of {_target} to survival
teleport {_target} to cs_lobby()
send "{@prefix}&cYou were removed from the Custom Server." to {_target}
cs_room_message({_room}, "&e%{_target}% was removed from the Custom Server.")
function cs_set_password(p: player, password: text):
set {_room} to cs_room_of({_p})
if {_room} is "":
send "{@message-not-room}" to {_p}
stop
if {burnoutcs.room.%{_room}%::owner} is not {_p}:
send "{@message-owner-only}" to {_p}
stop
if {_password} is "":
send "&cThe password cannot be empty." to {_p}
stop
set {burnoutcs.room.%{_room}%::password} to {_password}
send "{@prefix}{@message-password-set}" to {_p}
function cs_remove_password(p: player):
set {_room} to cs_room_of({_p})
if {_room} is "":
send "{@message-not-room}" to {_p}
stop
if {burnoutcs.room.%{_room}%::owner} is not {_p}:
send "{@message-owner-only}" to {_p}
stop
delete {burnoutcs.room.%{_room}%::password}
send "{@prefix}{@message-password-removed}" to {_p}