SetPlayerPosition
Jump to navigation
Jump to search
setPlayerPosition
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.
Moves a connected player to an authoritative world position.
Syntax
bool setPlayerPosition(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 authoritative move is accepted into the player's position-control queue; otherwise returns false.
Examples
Move a player two metres along the X axis:
local position = getPlayerPosition(playerId)
if position then
setPlayerPosition(playerId, position.x + 2, position.y, position.z)
end
Notes
- Available only in server-side resource scripts.
- Coordinates use metres. The server converts them to Unreal units before sending the reliable control event.
- The function may be called from
onPlayerJoin. Before the player's first valid movement snapshot, the accepted request remains queued and is dispatched as soon as that snapshot proves the native pawn is ready. - Position commands run one at a time. The server commits the transform and emits
onPlayerTeleportonly after a validated native ACK confirms that the exact command was applied.