TeleportPlayer

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

teleportPlayer

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.

Teleports a connected player to an authoritative world position.

Syntax

bool teleportPlayer(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 World X coordinate in metres.
y number yes World Y coordinate in metres.
z number yes World Z coordinate in metres.
yaw number no Optional actor yaw in degrees; defaults to 0.

Returns

Returns true when the teleport is accepted into the player's position-control queue; otherwise returns false.

Examples

Teleport a player to an RP spawn point:

teleportPlayer(playerId, 125.5, -48.0, 3.25, 180)

Notes

  • Available only in server-side resource scripts.
  • This is the explicit teleport alias of setPlayerPosition. Calls made before the first valid movement snapshot, including from onPlayerJoin, remain queued until the native pawn is ready.
  • The server commits the transform and emits onPlayerTeleport only after the native client acknowledges that it applied the queued command.
  • Coordinates use metres and yaw uses degrees.