Advanced Spawn

Learn how to make an advanced spawn system on your server.

Take a look at the code.

Options:
spawnOnJoin: true
spawnOnDeath: true
spawnDelay: 5
function checkMovement(x: number, x1: number, y: number, y1: number, z: number, z1: number) :: boolean:
{_x} != {_x1}:
set {_err} to true
{_y} != {_y1}:
set {_err} to true
{_z} != {_z1}:
set {_err} to true
{_err}:
return true
function spawn(p: player):
teleport {_p} to {spawn}
join:
{@spawnOnJoin}:
spawn(player)
death:
{@spawnOnDeath}:
spawn(victim)
command /setspawn:
permission: server.setspawn
permission message: {@np}
trigger:
set {spawn} to player's location
set {spawnpitch} to player's pitch
set {spawnyaw} to player's yaw
send "Spawn set &b(%player's location%&b, ""%player's world%&b"")"
command /spawn [<player>]:
usage: &c/spawn [player]
permission: server.spawn
permission message: {@np}
trigger:
arg-1 is set:
player has permission "server.spawn.others" or "":
arg-1 = player:
send "Teleporting..." to player
else:
send "Teleporting..." to player and arg-1
spawn(arg-1)
send "Teleported."
else:
send "&cInsufficient permissions."
else:
player has permission "server.spawn.bypassdelay":
send "Teleporting..."
spawn(player)
send "Teleported."
else:
send "Telporting to spawn in &b{@spawnDelay} &fseconds. Don't move!"
set {_x1} to player's x coordinate
set {_y1} to player's y coordinate
set {_z1} to player's z coordinate
loop ({@spawnDelay}+1) times:
{_n} = {@spawnDelay}:
send "Teleporting..." to player
spawn(player)
send "Teleported." to player
else:
add 1 to {_n}
wait 1 second
set {_x2} to player's x coordinate
set {_y2} to player's y coordinate
set {_z2} to player's z coordinate
checkMovement({_x1}, {_x2}, {_y1}, {_y2}, {_z1}, {_z2}):
send "&cTeleportation cancelled. You moved!" to player
stop

You can use the code above on your server to create a spawn system with a delay. You can also set whether not to teleport players to spawn on join and when they die.