fix(client/vehicleProperties): missing props and paint fixes (#396)

This commit is contained in:
Luxu
2023-08-15 01:37:27 +01:00
committed by GitHub
parent 1bd6d7c5ff
commit a97b9ba054

View File

@@ -10,6 +10,8 @@ if cache.game == 'redm' then return end
---@field fuelLevel? number ---@field fuelLevel? number
---@field oilLevel? number ---@field oilLevel? number
---@field dirtLevel? number ---@field dirtLevel? number
---@field paintType1? number
---@field paintType2? number
---@field color1? number | number[] ---@field color1? number | number[]
---@field color2? number | number[] ---@field color2? number | number[]
---@field pearlescentColor? number ---@field pearlescentColor? number
@@ -119,6 +121,8 @@ function lib.getVehicleProperties(vehicle)
---@type number | number[], number | number[] ---@type number | number[], number | number[]
local colorPrimary, colorSecondary = GetVehicleColours(vehicle) local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle) local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
local paintType1 = GetVehicleModColor_1(vehicle)
local paintType2 = GetVehicleModColor_2(vehicle)
if GetIsVehiclePrimaryColourCustom(vehicle) then if GetIsVehiclePrimaryColourCustom(vehicle) then
colorPrimary = { GetVehicleCustomPrimaryColour(vehicle) } colorPrimary = { GetVehicleCustomPrimaryColour(vehicle) }
@@ -191,6 +195,8 @@ function lib.getVehicleProperties(vehicle)
fuelLevel = math.floor(GetVehicleFuelLevel(vehicle) + 0.5), fuelLevel = math.floor(GetVehicleFuelLevel(vehicle) + 0.5),
oilLevel = math.floor(GetVehicleOilLevel(vehicle) + 0.5), oilLevel = math.floor(GetVehicleOilLevel(vehicle) + 0.5),
dirtLevel = math.floor(GetVehicleDirtLevel(vehicle) + 0.5), dirtLevel = math.floor(GetVehicleDirtLevel(vehicle) + 0.5),
paintType1 = paintType1,
paintType2 = paintType2,
color1 = colorPrimary, color1 = colorPrimary,
color2 = colorSecondary, color2 = colorSecondary,
pearlescentColor = pearlescentColor, pearlescentColor = pearlescentColor,
@@ -328,15 +334,19 @@ function lib.setVehicleProperties(vehicle, props)
ClearVehicleCustomPrimaryColour(vehicle) ClearVehicleCustomPrimaryColour(vehicle)
SetVehicleColours(vehicle, props.color1 --[[@as number]], colorSecondary --[[@as number]]) SetVehicleColours(vehicle, props.color1 --[[@as number]], colorSecondary --[[@as number]])
else else
if props.paintType1 then SetVehicleModColor_1(vehicle, props.paintType1, colorPrimary, pearlescentColor) end
SetVehicleCustomPrimaryColour(vehicle, props.color1[1], props.color1[2], props.color1[3]) SetVehicleCustomPrimaryColour(vehicle, props.color1[1], props.color1[2], props.color1[3])
end end
end end
if props.color2 then if props.color2 then
if type(props.color2) == 'number' then if type(props.color2) == 'number' then
ClearVehicleCustomPrimaryColour(vehicle) ClearVehicleCustomSecondaryColour(vehicle)
SetVehicleColours(vehicle, props.color1 or colorPrimary --[[@as number]], props.color2 --[[@as number]]) SetVehicleColours(vehicle, props.color1 or colorPrimary --[[@as number]], props.color2 --[[@as number]])
else else
if props.paintType2 then SetVehicleModColor_2(vehicle, props.paintType2, colorSecondary) end
SetVehicleCustomSecondaryColour(vehicle, props.color2[1], props.color2[2], props.color2[3]) SetVehicleCustomSecondaryColour(vehicle, props.color2[1], props.color2[2], props.color2[3])
end end
end end