Skip to content

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.

players.setPosition(player: PlayerTarget, position: Vector3, facingAngleRadians?: number, interior?: number, includeVehicle?: boolean): Promise<ActionResult>
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.

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.

A /grove command that takes the player home.

gamemodes/commands.ts
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);
});