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.
Signature
Section titled “Signature”players.stopSpectating(viewer: PlayerTarget, returnTo?: SpectateReturn): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
viewer |
PlayerTarget |
The spectator. |
returnTo |
SpectateReturn |
Optional. Where they go back to, on foot. |
Returns
Section titled “Returns”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.
Example
Section titled “Example”import { commands, players } from "nativemp";
commands.register("specoff", async (player) => { await players.stopSpectating(player, { position: [1544, -1675, 14], facingAngleRadians: 0, interior: 0 });});