playerCameraChangeRequest
Asks your gamemode before a player’s camera is set by camera.setFixed or
camera.attach. The player keeps playing under the new camera; to make them only
watch, use players.spectate, which asks
playerSpectateRequest instead.
Renamed in 0.28 from playerCameraRequest; see renamed names.
Signature
Section titled “Signature”server.on("playerCameraChangeRequest", ({ player, view }) => boolean | ViewDecision<CameraView> | void | Promise<boolean | ViewDecision<CameraView> | void>)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The player whose camera would change. |
view |
CameraView |
The view asked for: fixed, or attached to a target. |
Returns
Section titled “Returns”false or { decision: "deny" } keeps the camera as it is, and the call is rejected with view-denied.
{ decision: "allow", override } sets the CameraView override instead; a view the
server cannot use rejects the call with invalid-view-override. Anything else sets the view asked for. See
how decisions work.
Example
Section titled “Example”Only staff get cutscene cameras, and only outside interiors.
import { server } from "nativemp";
const staff = new Set(["Admin"]);
server.on("playerCameraChangeRequest", ({ player, view }) => { if (!staff.has(player.name)) return false; if (view.mode === "fixed" && (view.interior ?? 0) !== 0) return { decision: "deny" };});Related
Section titled “Related”camera.setFixed,camera.attachPlayerCameraChangeRequestPayloadplayerViewEnded: when the view ends