SpawnPlayer

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 18:40, 3 September 2026 by QCherry (talk | contribs) (Document Lua APIs available or improved from G1R:MP 0.1.2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

spawnPlayer

IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.

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 into the player's position-control queue; 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 is safe to call from onPlayerJoin. The server retains the request until the player's first valid movement snapshot proves that the native pawn is ready.
  • The server commits the spawn transform and emits onPlayerSpawn only after a validated native ACK confirms that the queued command was applied.
  • Spawning changes position but does not implicitly revive a dead player. Call revivePlayer when the gamemode requires it.