playerSpawnRequest
Asks your gamemode about every spawn: the first, and each respawn after a death or an arrest.
Renamed in 0.28 from spawnRequest; see renamed names.
Signature
Section titled “Signature”server.on("playerSpawnRequest", ({ player, spawnKind, position, facingAngleRadians }) => SpawnDecision | false | Promise<SpawnDecision | false>)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The player. |
spawnKind |
"initial" | "respawn" |
The first spawn, or one after dying or being arrested. |
position |
Vector3 |
Where the server would spawn them. |
facingAngleRadians |
number |
The facing the server would use, in radians. |
Returns
Section titled “Returns”{ decision: "allow" } spawns the player as the server would; { decision: "allow", spawn } chooses position, facingAngleRadians, skin, health and armour (each optional, ranges as in players.spawn), and { decision: "hold" } (or false) keeps the player held. Returning nothing spawns them. The first handler that
holds or allows decides. See how decisions work.
Example
Section titled “Example”Respawn at a hospital; the first spawn at Grove Street.
import { server } from "nativemp";
server.on("playerSpawnRequest", ({ spawnKind }) => { if (spawnKind === "initial") return { decision: "allow", spawn: { position: [2495.3, -1687.5, 13.5], skin: 0 } }; return { decision: "allow", spawn: { position: [1172.4, -1323.3, 15.4], health: 100 } }; // All Saints});Related
Section titled “Related”players.spawn: release a held playerplayerSpawned: the player is aliveserver.configure: what a timeout does