Client
Vehicle Properties

Vehicle Properties (Client)

RP.GetVehicleProperties and RP.SetVehicleProperties provide a complete snapshot of a vehicle's visual and performance state in a serializable table.


RP.GetVehicleProperties(vehicle)

Returns a VehicleProperties table for the given entity, or nil if the entity does not exist.

--- @param vehicle number  Entity handle
--- @return VehicleProperties?
local props = RP.GetVehicleProperties(veh)
if props then
    print(props.plate, props.color1, props.modEngine)
end

RP.SetVehicleProperties(vehicle, props)

Applies a previously captured (or manually constructed) properties table to a vehicle. Only present keys are applied — missing keys leave the vehicle unchanged.

--- @param vehicle number
--- @param props   VehicleProperties
RP.SetVehicleProperties(veh, props)

VehicleProperties fields

FieldTypeDescription
modelnumberEntity model hash
platestringPlate text
plateIndexnumberPlate style (0–5)
bodyHealthnumberBody health (0–1000)
engineHealthnumberEngine health (0–1000)
tankHealthnumberPetrol tank health (0–1000)
fuelLevelnumberFuel level (0–100)
dirtLevelnumberDirt level (0–15)
color1numberPrimary paint index
color2numberSecondary paint index
pearlescentColornumberPearlescent paint index
wheelColornumberWheel colour index
wheelsnumberWheel type
windowTintnumberWindow tint (0–6)
xenonColornumberXenon headlight colour
neonEnabledboolean[4]Neon lights enabled per side
neonColornumber[3]Neon RGB colour
tyreSmokeColornumber[3]Tyre smoke RGB colour
extrastable<string, boolean>Extra slot states (key = tostring(id))
modSpoilersmodWindowsnumberIndividual mod slots (0–24 etc.)
modTurbobooleanTurbo toggle
modXenonbooleanXenon toggle
modSmokeEnabledbooleanTyre smoke toggle
modLiverynumberLivery index

Example: save and restore

-- Save props before a race
local savedProps = RP.GetVehicleProperties(veh)
 
-- ... race happens, vehicle may get damaged ...
 
-- Restore afterwards
RP.SetVehicleProperties(veh, savedProps)

Example: store in RCVehicle.data

-- Server callback to save vehicle appearance
RP.RegisterServerCallback('garage:save', function(src, cb, plate, props)
    local v = RP.GetVehicleByPlate(plate)
    if not v then return cb(false) end
    v.data.props = props
    v:saveData()
    cb(true)
end)
 
-- Client side
RP.TriggerServerCallback('garage:save', function(ok)
    print(ok and "Saved!" or "Failed")
end, RP.Util.Trim(GetVehicleNumberPlateText(veh)), RP.GetVehicleProperties(veh))