Skip to content

OnPlayerRequestSpawn

The client’s level is ready - decide where the player spawns, or hold them.

Set the spawn point with SetSpawnInfo and return true (or nothing): the player is spawned there - or at the server’s default point without one - and OnPlayerSpawn follows. Return false to hold the player: their screen says “waiting for the spawn” until the mode calls SpawnPlayer - a lobby, a team pick, a class menu. Called once per level load, not on respawns.

function OnPlayerRequestSpawn(pid)
-- ...
end
Parameter Type
pid number the player

true or nothing spawns the player now; false holds them until SpawnPlayer

function OnPlayerRequestSpawn(pid)
local last = GetPlayerData(pid, "last_position") -- a mode's own record, loaded from its database on the connect
if last then
SetSpawnInfo(pid, last.x, last.y, last.z, last.yaw) -- back where they left
else
SetSpawnInfo(pid, spawnX + 1.5 * (pid % 16), spawnY, spawnZ, spawnYaw)
end
return true
end

SetSpawnInfo · SpawnPlayer · OnPlayerSpawn · the Players group of the index