Skip to content
M2O Scripting APIScripting reference
Data shapeClient APIGenerated

RenderTargetSurface

Defined in: client/api.d.ts:770

An offscreen surface registered with the engine’s texture registry. Pass its name to Material.setTexture to make any world material draw it.

captureScreen(): boolean

Defined in: client/api.d.ts:826

Copies the frame the game is about to show into the target, before any M2O overlay is composited onto it. This is the security-camera-showing-your-own-view effect.

boolean


clear(color?): boolean

Defined in: client/api.d.ts:821

Wipes the target.

Color

The colour to wipe with; transparent by default.

boolean


destroy(): boolean

Defined in: client/api.d.ts:855

Releases this handle. Clear any material sampler still bound to its name first, because the surface goes back to a pool and may be handed to another target.

boolean


draw(commands, options?): boolean

Defined in: client/api.d.ts:815

Replaces the target’s contents. The painting itself happens on the next frame, so calling this every tick is what animates a screen.

RenderTargetCommand[]

The frame to draw; it replaces whatever the target showed.

RenderTargetDrawOptions

boolean


drawModel(options): boolean

Defined in: client/api.d.ts:838

Experimental. Shows one model alone, lit by the world, in an opaque target (create it with { alpha: false }). Returns false while the model streams in, so call it every tick; changing rotation between calls turns it. stopWorld removes it.

model is the registry name used by Vehicle.spawn, setModel or Prop.create; rotation is Euler angles in radians; pitch and fov are degrees.

number

number

"vehicle" | "ped" | "prop"

string

number

Vector3

boolean


probePixel(x, y): boolean

Defined in: client/api.d.ts:850

Asks for one pixel to be read back to the CPU. The copy runs on the next present, so read it with probedPixel a frame later. Combined with captureScreen this is how a script inspects what the game actually drew.

number

Pixel column inside the target.

number

Pixel row inside the target.

boolean


renderWorld(options?): boolean

Defined in: client/api.d.ts:832

Experimental. Renders the game world into an opaque target (create it with { alpha: false }) through a second engine render destination until stopWorld. Returns false until the target is ready and on the call that creates the view, so call it every tick; that is also how the view moves.

Without position and target the view copies the gameplay camera.

number

Vector3

Vector3

boolean


stopWorld(): boolean

Defined in: client/api.d.ts:843

Experimental. Detaches the view started by renderWorld or drawModel and removes any model it showed.

boolean

readonly destroyed: boolean

Defined in: client/api.d.ts:804

Whether this handle is no longer valid.


readonly height: number

Defined in: client/api.d.ts:784

Target height in pixels.


readonly id: number

Defined in: client/api.d.ts:774

Opaque render target identifier.


readonly name: bigint

Defined in: client/api.d.ts:789

The texture name a material sampler binds, for Material.setTexture.


readonly path: string

Defined in: client/api.d.ts:794

The virtual-file-system style name the texture is registered under. Anything that takes a texture path rather than a name, such as a Render2D texture node, can bind the target through this.


readonly probedPixel: number | null

Defined in: client/api.d.ts:809

The last pixel read back by probePixel, packed as ARGB, or null if none has completed.


readonly ready: boolean

Defined in: client/api.d.ts:799

Whether the surface exists on the GPU yet. The engine creates it a frame or two after create, and it goes false again across an alt-tab.


readonly width: number

Defined in: client/api.d.ts:779

Target width in pixels.