SpawnPlayer: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Complete Lua function catalog
Document Lua APIs available or improved from G1R:MP 0.1.2
 
Line 1: Line 1:
<!-- This page is generated automatically from the function definition: spawnPlayer. -->
= spawnPlayer =
= spawnPlayer =
<div style="background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;">
<div style="color:#111111; font-weight:bold; letter-spacing:0.04em;">IMPROVED FROM UPDATE 0.1.2</div>
<div style="color:#111111; margin-top:0.25rem;">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.</div>
</div>
Places a connected player at an authoritative spawn position.
Places a connected player at an authoritative spawn position.


Line 24: Line 28:


== Returns ==
== Returns ==
Returns <code>true</code> when the spawn action is accepted and queued; otherwise returns <code>false</code>.
Returns <code>true</code> when the spawn action is accepted into the player's position-control queue; otherwise returns <code>false</code>.


== Examples ==
== Examples ==
Line 36: Line 40:
== Notes ==
== Notes ==
* Available only in server-side resource scripts.
* Available only in server-side resource scripts.
* This function emits <code>onPlayerSpawn</code> when accepted.
* This function is safe to call from <code>onPlayerJoin</code>. 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 <code>onPlayerSpawn</code> 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 <code>revivePlayer</code> when the gamemode requires it.
* Spawning changes position but does not implicitly revive a dead player. Call <code>revivePlayer</code> when the gamemode requires it.



Latest revision as of 18:40, 3 September 2026

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.