SpawnPlayer
spawnPlayer
Places a connected player at an authoritative spawn position.
Syntax
bool spawnPlayer(int playerId, number x, number y, number z [, number yaw = 0])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
x |
number |
yes | Spawn X coordinate in metres. |
y |
number |
yes | Spawn Y coordinate in metres. |
z |
number |
yes | Spawn Z coordinate in metres. |
yaw |
number |
no | Optional actor yaw in degrees; defaults to 0. |
Returns
Returns true when the spawn action is accepted and queued; otherwise returns false.
Examples
Spawn newly connected players at a fixed location:
addEventHandler("onPlayerJoin", root, function(playerId)
spawnPlayer(playerId, 12.0, 24.0, 2.0, 90)
end)
Notes
- Available only in server-side resource scripts.
- This function emits
onPlayerSpawnwhen accepted. - Spawning changes position but does not implicitly revive a dead player. Call
revivePlayerwhen the gamemode requires it.