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.
Signature
Section titled “Signature”vehicles.setVirtualWorld(id: number, virtualWorld: number): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
id |
number |
The vehicle’s ID. |
virtualWorld |
number |
The virtual world, 0 to 2147483647. |
Returns
Section titled “Returns”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).
Example
Section titled “Example”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] });});Related
Section titled “Related”players.setVirtualWorld: a player, with their vehicle if you askvirtualWorldChangeRequest: refuse or redirect a move- Virtual worlds