virtualWorldChangeRequest
Asks your gamemode before a player, or a vehicle with everyone in it, goes to another virtual world: on every
players.setVirtualWorld and
vehicles.setVirtualWorld, and when a player who came back within two
minutes would go back to their virtual world.
Renamed in 0.28 from worldChangeRequest; see renamed names.
Signature
Section titled “Signature”server.on("virtualWorldChangeRequest", ({ player, vehicleId, fromVirtualWorld, toVirtualWorld, reason }) => boolean | number | void | Promise<boolean | number | void>)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot | null |
The player who would go, or null for a vehicle moved on its own. |
vehicleId |
number | null |
The vehicle that would go with everyone in it, or null for a player on foot. |
fromVirtualWorld |
number |
The virtual world they are in. |
toVirtualWorld |
number |
The virtual world they would go to. |
reason |
"script" | "reconnect" |
"script": a gamemode’s call. "reconnect": a returning player. |
Returns
Section titled “Returns”false keeps them where they are, and the call is rejected with vetoed. A number sends them to that virtual world
instead; the call’s createdId says where they went. Anything else lets them go. See
how decisions work.
Example
Section titled “Example”A staff-only virtual world, and a lobby for a returning player.
import { server } from "nativemp";
const staffWorld = 900, lobbyWorld = 1;const staff = new Set(["Admin"]);
server.on("virtualWorldChangeRequest", ({ player, toVirtualWorld, reason }) => { if (toVirtualWorld === staffWorld && !staff.has(player?.name ?? "")) return false; if (reason === "reconnect") return lobbyWorld;});Related
Section titled “Related”playerVirtualWorldChanged: after the moveVirtualWorldChangeRequestPayload- Virtual worlds