mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #1637 from l2rhydra/main
Refactored Set vehicle Properties
This commit is contained in:
@@ -806,14 +806,18 @@ function ESX.Game.GetVehicleProperties(vehicle)
|
||||
return
|
||||
end
|
||||
|
||||
---@type number | number[], number | number[]
|
||||
local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
|
||||
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
|
||||
local hasCustomPrimaryColor = GetIsVehiclePrimaryColourCustom(vehicle)
|
||||
local dashboardColor = GetVehicleDashboardColor(vehicle)
|
||||
local interiorColor = GetVehicleInteriorColour(vehicle)
|
||||
local customPrimaryColor = nil
|
||||
if hasCustomPrimaryColor then
|
||||
customPrimaryColor = { GetVehicleCustomPrimaryColour(vehicle) }
|
||||
|
||||
if GetIsVehiclePrimaryColourCustom(vehicle) then
|
||||
colorPrimary = { GetVehicleCustomPrimaryColour(vehicle) }
|
||||
end
|
||||
|
||||
if GetIsVehicleSecondaryColourCustom(vehicle) then
|
||||
colorSecondary = { GetVehicleCustomSecondaryColour(vehicle) }
|
||||
end
|
||||
|
||||
local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle)
|
||||
@@ -822,12 +826,6 @@ function ESX.Game.GetVehicleProperties(vehicle)
|
||||
customXenonColor = { customXenonColorR, customXenonColorG, customXenonColorB }
|
||||
end
|
||||
|
||||
local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle)
|
||||
local customSecondaryColor = nil
|
||||
if hasCustomSecondaryColor then
|
||||
customSecondaryColor = { GetVehicleCustomSecondaryColour(vehicle) }
|
||||
end
|
||||
|
||||
local extras = {}
|
||||
for extraId = 0, 20 do
|
||||
if DoesExtraExist(vehicle, extraId) then
|
||||
@@ -880,8 +878,6 @@ function ESX.Game.GetVehicleProperties(vehicle)
|
||||
dirtLevel = ESX.Math.Round(GetVehicleDirtLevel(vehicle), 1),
|
||||
color1 = colorPrimary,
|
||||
color2 = colorSecondary,
|
||||
customPrimaryColor = customPrimaryColor,
|
||||
customSecondaryColor = customSecondaryColor,
|
||||
|
||||
pearlescentColor = pearlescentColor,
|
||||
wheelColor = wheelColor,
|
||||
@@ -992,17 +988,19 @@ function ESX.Game.SetVehicleProperties(vehicle, props)
|
||||
if props.dirtLevel ~= nil then
|
||||
SetVehicleDirtLevel(vehicle, props.dirtLevel + 0.0)
|
||||
end
|
||||
if props.customPrimaryColor ~= nil then
|
||||
SetVehicleCustomPrimaryColour(vehicle, props.customPrimaryColor[1], props.customPrimaryColor[2], props.customPrimaryColor[3])
|
||||
end
|
||||
if props.customSecondaryColor ~= nil then
|
||||
SetVehicleCustomSecondaryColour(vehicle, props.customSecondaryColor[1], props.customSecondaryColor[2], props.customSecondaryColor[3])
|
||||
end
|
||||
if props.color1 ~= nil then
|
||||
SetVehicleColours(vehicle, props.color1, colorSecondary)
|
||||
if type(props.color1) == "table" then
|
||||
SetVehicleCustomPrimaryColour(vehicle, props.color1[1], props.color1[2], props.color1[3])
|
||||
else
|
||||
SetVehicleColours(vehicle, props.color1, colorSecondary)
|
||||
end
|
||||
end
|
||||
if props.color2 ~= nil then
|
||||
SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2)
|
||||
if type(props.color2) == "table" then
|
||||
SetVehicleCustomSecondaryColour(vehicle, props.color2[1], props.color2[2], props.color2[3])
|
||||
else
|
||||
SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2)
|
||||
end
|
||||
end
|
||||
if props.pearlescentColor ~= nil then
|
||||
SetVehicleExtraColours(vehicle, props.pearlescentColor, wheelColor)
|
||||
|
||||
Reference in New Issue
Block a user