SetPlayerPosition: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Document Lua APIs available or improved from G1R:MP 0.1.2 |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
= setPlayerPosition = | = setPlayerPosition = | ||
<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> | |||
Moves a connected player to an authoritative world position. | Moves a connected player to an authoritative world position. | ||
| Line 24: | Line 28: | ||
== Returns == | == Returns == | ||
Returns <code>true</code> when the authoritative move is accepted | Returns <code>true</code> when the authoritative move is accepted into the player's position-control queue; otherwise returns <code>false</code>. | ||
== Examples == | == Examples == | ||
| Line 38: | Line 42: | ||
* Available only in server-side resource scripts. | * Available only in server-side resource scripts. | ||
* Coordinates use metres. The server converts them to Unreal units before sending the reliable control event. | * Coordinates use metres. The server converts them to Unreal units before sending the reliable control event. | ||
* The player | * The function may be called from <code>onPlayerJoin</code>. 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 <code>onPlayerTeleport</code> only after a validated native ACK confirms that the exact command was applied. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Spatial Functions]] | [[Category:Spatial Functions]] | ||
Latest revision as of 18:40, 3 September 2026
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.