playerViewEnded
Tells your gamemode that a player’s camera view from camera.setFixed or
camera.attach ended, or that they stopped spectating. By then the player has their
own camera back, and a spectator is back in their vehicle seat or on foot.
Signature
Section titled “Signature”server.on("playerViewEnded", ({ player, mode, target, endReason }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The player whose view ended. |
mode |
"camera" | "spectating" |
A camera view, or spectating. |
target |
CameraTarget | SpectateTarget | null |
What they watched; null for a fixed camera. A player who has left is their ID. |
endReason |
PlayerViewEndReason |
Why it ended. |
Example
Section titled “Example”import { chat, server } from "nativemp";
server.on("playerViewEnded", ({ player, mode, endReason }) => { if (mode === "spectating" && endReason !== "script") { chat.sendServerMessage(`You stopped spectating (${endReason}).`, player); }});