Skip to content

vehicles.setVirtualWorld

Moves a vehicle to another virtual world, with every player in it and whatever it tows. Any vehicle, not only your own. A vehicle with nobody in it stays in the new virtual world: your own vehicles wait there, and one of the game’s traffic is removed when no player in that virtual world is near it.

Renamed in 0.28 from vehicles.setWorld; see renamed names.

vehicles.setVirtualWorld(id: number, virtualWorld: number): Promise<ActionResult>
Name Type Description
id number The vehicle’s ID.
virtualWorld number The virtual world, 0 to 2147483647.

A promise of an ActionResult: applied with createdId the vehicle’s virtual world, or rejected with invalid-vehicle-id, invalid-vehicle, invalid-world or vetoed (virtualWorldChangeRequest kept it there).

gamemodes/my-mode.ts
import { commands, players, vehicles } from "nativemp";
const raceWorld = 42;
commands.register("race", async (player) => {
if (player.vehicleId !== null) await vehicles.setVirtualWorld(player.vehicleId, raceWorld);
await players.setRaceCheckpoint(player, { position: [1810, -2490, 13.5] });
});