Skip to content

objects.getById

Returns one of your objects by its ID, or undefined when there is none.

Renamed in 0.28 from objects.get; see renamed names.

objects.getById(id: number): ScriptObject | undefined
Name Type Description
id number The ID returned by objects.create.

The ScriptObject, or undefined.

gamemodes/my-mode.ts
import { objects, server } from "nativemp";
const objectId = 0; // the ID objects.create returned
const object = objects.getById(objectId);
if (object) server.log(`Model ${object.model} is in interior ${object.interior}`);