objects.beginEdit
Opens the editor on a nearby object your gamemode placed. The player drags the X, Y and Z handles to move or rotate it, or drags the center handle to scale it uniformly. The toolbar and keys 1, 2 and 3 select the tool. Shift gives finer control. Ctrl snaps the position to a 0.25 m grid, the scale to 0.1 steps and each turn to 15 degrees.
The player holds Space and moves the mouse to orbit, middle-drags to pan, scrolls to zoom and presses F to frame the object. Releasing Space returns the pointer to where it was before orbiting. Enter saves and Esc cancels.
World objects use world axes. Attached objects use their parent’s axes and stay attached when saved. The selected player alone sees the draft. An accepted save updates the shared object and is reported by playerObjectEditEnded. Scaling changes the appearance. Collision keeps the game’s original shape.
Only the camera goes to the object. The player’s body stays where it stood and does not move while the editor is open. Other players see it standing still, and it can still be shot, run over or burned. If the player dies, opens the pause menu or chat, or changes interior, the editor closes and playerObjectEditEnded reports object-edit-unavailable. To keep an editing player out of harm, move them somewhere safe before you call this.
Signature
Section titled “Signature”objects.beginEdit(player: PlayerTarget, id: number): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player who will edit the object. |
id |
number |
The ID from objects.create. |
Returns
Section titled “Returns”An ActionResult. applied means the player opened the editor. The player must be spawned and able to see the object in their current interior and virtual world. Only one player may edit an object at a time, and each player may edit one object at a time. Objects in a timed move become editable when the move finishes. The editor closes if the object leaves the player’s view or its transform changes by script.
Example
Section titled “Example”import { chat, commands, objects } from "nativemp";
const prop = await objects.create({ model: 1337, position: [2495, -1668, 14] });
commands.register("editprop", async (player) => { if (prop.status !== "applied" || prop.createdId === undefined) return; const result = await objects.beginEdit(player, prop.createdId); if (result.status !== "applied") chat.sendServerMessage("The prop is unavailable for editing.", player);});