getRandomPaintsByVehicle
Definition
-- @/lua/ge/extensions/core/vehiclePaints.lua:594
-- gets random paints to use for an existing vehicle
local function getRandomPaintsByVehicle(vehId)
local obj = getObjectByID(vehId or 0)
local model = obj and obj.jbeam
local config = obj and tostring(obj.partConfig)
config = string.match(config, "vehicles/".. model .."/(.*).pc")
if not obj or not config then
log('W', 'getRandomPaint', 'Vehicle not found, now using default paint data')
return {'White', 'White', 'White'}
end
local paints = getRandomPaints(model, config)
if not paints then
log('W', 'getRandomPaintsByVehicle', 'Failed to get random paints for vehicle ' .. vehId .. ', now using default paint data')
return {'White', 'White', 'White'}
end
--log("I","",string.format("Selected for model %s, config %s: %s %s %s", model, config, paints.paintName1, paints.paintName2, paints.paintName3))
return {paints.paintName1, paints.paintName2, paints.paintName3} -- returns as an array so that the function setVehicleColorsNames can use it
end
Callers
@/lua/ge/extensions/gameplay/traffic/vehicle.lua
-- selects a random set of 3 paints
paints = core_vehiclePaints.getRandomPaintsByVehicle(self.id)
end
@/lua/ge/extensions/gameplay/parking.lua
if parkedVehData[vehId].randomPaint then
core_vehicle_manager.setVehiclePaintsNames(vehId, core_vehiclePaints.getRandomPaintsByVehicle(vehId))
end