ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. createElementPreview

Function

createElementPreview

ClientGame engineTrilogy Hub only

Creates a preview of an element (a vehicle, a player, a ped, an object, a model object) as an image for dxDrawImage, e.g. for a car shop or a wardrobe. false as the target = the scene from the camera. By default the camera orbits the target so that it fits in the frame.

Syntax

preview createElementPreview(element|bool target [, int width = 256, int height])

Arguments

targetelement|bool
The preview target.
widthint, optional = 256
Image width.
heightint, optional
Image height (same as the width by default).

Returns

The preview or false.

Example

The player's car turning in the corner of the screen.

local veh = getPedOccupiedVehicle(localPlayer)
local preview = veh and createElementPreview(veh, 320, 200)
addEventHandler("onClientRender", root, function()
    if not preview then return end
    setElementPreviewOrbit(preview, getTickCount() / 30 % 360, 15)
    local img = getElementPreviewImage(preview)
    if img then dxDrawImage(20, 20, 320, 200, img) end
end)

Notes

No camera setup. A model preview needs no manual object and camera placement and no external resources.

See also