Developer

2 min readUpdated Today

Overview

ML Autocapture exposes server helpers for opening the studio and resolving generated images. The full edition also exposes a client capture function for existing entities.

Server exports

Open the studio

  • OpenStudio(source) — Opens the full studio for a real player source. Returns true when the request is accepted or false when the resource is locked or the source is invalid.
lua
1local opened = exports['ml_autocapture']:OpenStudio(source)

Resolve generated images

  • getImage(key) — Returns a nui:// URL for the first matching PNG, JPG or WebP in the self-contained output and then ox_inventory. Returns nil when no image exists.
  • getImages(keys) — Resolves an array of keys and returns a table keyed by the original values.
lua
1local url = exports['ml_autocapture']:getImage('model_windowway_metal')
2local urls = exports['ml_autocapture']:getImages({ 'adder', 'sultan', 'model_windowway_metal' })

Vehicle configurator output

  • getConfiguratorManifest(model) — Returns the decoded configurator manifest for a model or nil.
  • getConfiguratorImage(model, file) — Returns the nui:// URL for a generated configurator layer or nil.
lua
1local manifest = exports['ml_autocapture']:getConfiguratorManifest('adder')
2local layer = exports['ml_autocapture']:getConfiguratorImage('adder', 'front_bumper_0.png')

Client exports

Admin menu integration

  • MLAdminPanel() — Returns the admin-menu label and icon when the command is enabled.
  • MLAdminOpen() — Executes the configured studio command.
lua
1local entry = exports['ml_autocapture']:MLAdminPanel()
2exports['ml_autocapture']:MLAdminOpen()

Capture an existing entity

  • CaptureEntity(entity, key, options?) — Moves an existing vehicle or ped into the studio, creates a transparent image in the self-contained output, restores the entity and returns its nui:// URL. Returns nil if the studio is busy, the entity is invalid or capture fails.
lua
1local url = exports['ml_autocapture']:CaptureEntity(entity, 'preview_vehicle', {
2    width = 512,
3    height = 512,
4    format = 'png',
5    quality = 92,
6    yaw = 35.0,
7    pitch = -8.0,
8    fov = 40.0,
9    margin = 1.25,
10    returnData = false,
11})

Supported options are width, height, format, quality, yaw, pitch, fov, margin and returnData.

Client event

  • ml_autocapture:entityCaptured — Fires locally after CaptureEntity completes. Parameters are the sanitized key and the resulting URL or nil.
lua
1AddEventHandler('ml_autocapture:entityCaptured', function(key, url)
2    if not url then return end
3    print(key, url)
4end)

File naming

Capture keys are converted to lowercase and stripped to letters, digits, underscores and dashes. Prop batches use each entry's item value as the key and use model only for spawning the object.