Skip to content

players.stopSpectating

Ends spectating. The player goes back to the vehicle seat they watched from if the vehicle is still there and the seat is free, wherever the vehicle is now; otherwise they go back on foot to where they started watching. Their seat is not kept for them while they watch.

Give returnTo to put them on foot somewhere else instead.

players.stopSpectating(viewer: PlayerTarget, returnTo?: SpectateReturn): Promise<ActionResult>
Name Type Description
viewer PlayerTarget The spectator.
returnTo SpectateReturn Optional. Where they go back to, on foot.

A promise of an ActionResult: applied once they are back, rejected with a code (not-spectating, invalid-view-return, player-not-found), or timeout after 21 seconds without an answer.

gamemodes/my-mode.ts
import { commands, players } from "nativemp";
commands.register("specoff", async (player) => {
await players.stopSpectating(player, { position: [1544, -1675, 14], facingAngleRadians: 0, interior: 0 });
});