players.stopFreecam
Ends a freecam started with players.freecam. returnTo picks where the player
goes; see FreecamReturn. By default ("auto") a player who started in a vehicle goes
back to their seat, and anyone else lands on the ground under the camera.
When the freecam ends some other way (the gamemode stops, the player changes virtual world), they always go back to
where they started, as with "previous".
Signature
Section titled “Signature”players.stopFreecam(viewer: PlayerTarget, returnTo?: FreecamReturn): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
viewer |
PlayerTarget |
The player who flies. |
returnTo |
FreecamReturn |
Optional. Where they go: "auto" (default), "previous", "camera" or a point on foot. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once they are back, rejected with a code, or
timeout after 21 seconds without an answer.
| Code | Meaning |
|---|---|
not-in-freecam |
The player is not flying a freecam. A spectator keeps watching; end that with players.stopSpectating. |
invalid-view-return |
returnTo is not one of the values above or a valid point. |
view-change-pending |
The player is still on their way into the freecam; try again in a moment. |
player-not-found |
No such player, or they left meanwhile. |
Example
Section titled “Example”import { commands, players } from "nativemp";
commands.register("land", async (player) => { await players.stopFreecam(player, "camera");});