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.
exports.evolent_studio:GetPhoto(model, version, primary, secondary, cb)| Parameter | Type | Description |
|---|---|---|
model | string | Spawn code, such as 'adder'. |
version | number? | From GetVersion. A higher version than the one in memory loads the new photo. nil uses the one in memory. |
primary | string | Primary colour as '#RRGGBB'. |
secondary | string? | Secondary colour as '#RRGGBB'. Defaults to primary. |
cb | function | Called with the image, or nil. |
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.
exports.evolent_studio:GetPaint(properties)| Parameter | Type |
|---|---|
properties | table | 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.
exports.evolent_studio:GetVersion(model)| Parameter | Type |
|---|---|
model | string | number |
Returns a number, or nil when the model has no photo.
HasPhoto
Whether a model has a photo.
exports.evolent_studio:HasPhoto(model)| Parameter | Type |
|---|---|
model | string | number |
Returns a boolean.
GetUrl
The link of a model's uploaded photo. See Uploads.
exports.evolent_studio:GetUrl(model)| Parameter | Type |
|---|---|
model | string | 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:
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)