Studio/Exports

Exports

Show the photos in your own resources.

Studio pages

A photo is stored once per model. To show a player's car, read its paint on the server with GetPaint, then paint the photo on the client with GetPhoto.

Client Exports

GetPhoto

Paints the photo of a model in the given colours and passes it to cb as a data:image/webp link, which works as the src of an image in your NUI. cb gets nil when the model has no photo.

Lua
exports.evolent_studio:GetPhoto(model, version, primary, secondary, cb)
ParameterTypeDescription
modelstringSpawn code, such as 'adder'.
versionnumber?From GetVersion. A higher version than the one in memory loads the new photo. nil uses the one in memory.
primarystringPrimary colour as '#RRGGBB'.
secondarystring?Secondary colour as '#RRGGBB'. Defaults to primary.
cbfunctionCalled with the image, or nil.
Example
exports.evolent_studio:GetPhoto('adder', nil, '#E11D2A', '#16161A', function(image)
    if image then
        SendNUIMessage({ action = 'carPhoto', model = 'adder', image = image })
    end
end)

Photos are cached on the client, so asking for the same car again is instant. Players who ask for many photos at once are rate limited and get nil until they slow down.

Server Exports

GetPaint

Reads the paint from saved vehicle properties, as a table or its JSON. Custom colours win over the paint index.

Lua
exports.evolent_studio:GetPaint(properties)
ParameterType
propertiestable | string

Returns { primary = '#RRGGBB', secondary = '#RRGGBB' }, or nil when the properties have no paint.

GetVersion

The version of a model's photo. It changes every time the photo is retaken.

Lua
exports.evolent_studio:GetVersion(model)
ParameterType
modelstring | number

Returns a number, or nil when the model has no photo.

HasPhoto

Whether a model has a photo.

Lua
exports.evolent_studio:HasPhoto(model)
ParameterType
modelstring | number

Returns a boolean.

GetUrl

The link of a model's uploaded photo. See Uploads.

Lua
exports.evolent_studio:GetUrl(model)
ParameterType
modelstring | number

Returns a string, or nil when the photo was not uploaded.

Example

A garage menu that shows each owned car in its own paint:

server.lua
lib.callback.register('mygarage:photoInfo', function(source, model, properties)
    local paint = exports.evolent_studio:GetPaint(properties)

    if not paint or not exports.evolent_studio:HasPhoto(model) then
        return nil
    end

    return {
        version = exports.evolent_studio:GetVersion(model),
        primary = paint.primary,
        secondary = paint.secondary,
    }
end)