playerVirtualWorldChanged
Tells your gamemode that a player went to another virtual world, once for each player: a vehicle moved with three
players in it sends it three times. By then the virtual world they left is gone from their screen, and whatever they
were doing there has ended. virtualWorldChangeRequest came first.
Renamed in 0.28 from playerWorldChange; see renamed names.
Signature
Section titled “Signature”server.on("playerVirtualWorldChanged", ({ player, fromVirtualWorld, toVirtualWorld, reason }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The player, already in the new virtual world. |
fromVirtualWorld |
number |
The virtual world they left. |
toVirtualWorld |
number |
The virtual world they are in. |
reason |
"script" | "reconnect" |
"script": a gamemode moved them. "reconnect": they came back within two minutes and went back to their virtual world. |
Example
Section titled “Example”import { chat, server } from "nativemp";
server.on("playerVirtualWorldChanged", ({ player, toVirtualWorld }) => { chat.sendServerMessage(`You are in virtual world ${toVirtualWorld}.`, player);});