players.setPosition
Moves a player to a position in the world. By default, a seated player leaves their vehicle behind through GTA:SA’s instant exit routine. Pass true as the fifth argument, includeVehicle, to move the occupied vehicle and everyone inside it together, stopping the vehicle.
Signature
Section titled “Signature”players.setPosition(player: PlayerTarget, position: Vector3, facingAngleRadians?: number, interior?: number, includeVehicle?: boolean): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player, or their ID. |
position |
Vector3 |
[x, y, z] in game units (metres). x and y within ±6000, z from -500 to 2000; z is height. |
facingAngleRadians |
number |
Optional facing, in radians. Without it the player keeps their facing. |
interior |
number |
Optional. Also put the player in this interior: 0 outside, 1 to 18 an interior’s. Use it with a position inside that interior. |
includeVehicle |
boolean |
Optional, defaults to false. Move the player’s occupied vehicle and its occupants too. This also works when the selected player is a passenger. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once the player’s game has carried it out, rejected with a code, or timeout after five seconds without an answer.
Example
Section titled “Example”A /grove command that takes the player home.
import { chat, commands, players } from "nativemp";
commands.register("grove", async (player) => { // Grove Street, Ganton const result = await players.setPosition(player, [2495.3, -1687.5, 13.5], Math.PI); if (result.status === "applied") chat.sendServerMessage("Welcome home.", player);});
// Keep everyone seated while moving their vehicle to Grove Street.commands.register("grovecar", async player => { await players.setPosition(player, [2495.3, -1687.5, 13.5], Math.PI, 0, true);});Related
Section titled “Related”PlayerSnapshot:positionandfacingAngleRadiansread where a player isplayers.putInVehicle: seat a player in a vehicle- Async handlers: pass the
PlayerSnapshot, not its ID, after anawait