objects.create
Places an object for nearby players in the same interior and virtual world. It stays at the position you set until you edit or remove it.
Signature
Section titled “Signature”objects.create(settings: ScriptObjectSettings): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
settings.model |
number |
A stock GTA:SA world-object model ID, such as 1337. Ped, vehicle, weapon, cutscene-only and undefined IDs return invalid-model, as do gang tags and the 1373 train crossing, which only work as the map’s own copies. |
settings.position |
Vector3 |
World position [x, y, z]; x and y must be within ±6000, z from -500 to 2000. |
settings.rotationDegrees |
Vector3 |
Optional GTA:SA Euler angles in degrees [x, y, z]; defaults to [0, 0, 0]. Each angle must be within ±3600. |
settings.interior |
number |
Optional. 0 outside (the default), 1 to 18 an interior’s, 13 every interior: players in any interior see and can use it. |
settings.virtualWorld |
number |
Optional. The virtual world it is in, or virtualWorlds.every for every one. Defaults to 0. |
settings.interactive |
boolean |
Optional; true lets a player press Enter within 2.5 m to request a use. Defaults to false. |
settings.scale |
number |
Optional visual scale from 0.01 to 10. Defaults to 1. |
Returns
Section titled “Returns”A promise of an ActionResult. applied has the new object’s ID in createdId; read the
ScriptObject with objects.getById. Invalid settings return invalid-model,
invalid-position, invalid-rotation, invalid-area, invalid-world or invalid-interactive. The server holds up to 100,000 objects
(host-object-limit when full); object-id-space-exhausted means it has used up its object IDs until it restarts.
too-many-pending-actions means 128 actions are already waiting for an answer: the object was not created. Create a
large map in batches of 64 and await each batch.
Example
Section titled “Example”import { objects, server } from "nativemp";
const result = await objects.create({ model: 1337, position: [1750, -2490, 14], rotationDegrees: [0, 0, 45], interactive: true,});
if (result.status === "applied") { server.log(`Object ${result.createdId} is ready`);}Each player sees the nearest 1,000 of your objects in their interior and virtual world: an object comes in within 300 m and goes beyond
350 m. Players who join later see them too. The objects stay when players leave, and go when your gamemode stops or
reloads. A player’s use of an interactive object goes through
playerStartInteractionRequest; it has no effect of its own.
You can await objects.create(...) at the top of your gamemode while it loads. A load must finish within 30 seconds,
about 50,000 objects; create a larger map after the gamemode is ready. Objects created
during the load are in objects.listAll() at once but raise no
scriptObjectCreated.
Related
Section titled “Related”objects.destroy: remove itobjects.setTransformobjects.attachobjects.setMaterialsobjects.listAll: list the gamemode’s objectsscriptObjectCreated: an object was placed