From 9d91ba01952a65900dbf7d9f78b16c3e98cf3c55 Mon Sep 17 00:00:00 2001 From: Muhammed Yaseen Date: Fri, 9 May 2025 07:51:40 +0530 Subject: [PATCH 1/5] Refatored Set vehicle Properties --- [core]/es_extended/client/functions.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 8a577e7e..42a2a912 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -997,12 +997,23 @@ function ESX.Game.SetVehicleProperties(vehicle, props) 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) end From 542b143e750bc6e7de6709274a65074dc2d25320 Mon Sep 17 00:00:00 2001 From: Muhammed Yaseen Date: Fri, 9 May 2025 08:34:46 +0530 Subject: [PATCH 2/5] Removed duplication of Custom primary and secondary colors --- [core]/es_extended/client/functions.lua | 9 --------- 1 file changed, 9 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 42a2a912..71ed4882 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -991,13 +991,6 @@ 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 if type(props.color1) == "table" then SetVehicleCustomPrimaryColour(vehicle, props.color1[1], props.color1[2], props.color1[3]) @@ -1005,7 +998,6 @@ function ESX.Game.SetVehicleProperties(vehicle, props) SetVehicleColours(vehicle, props.color1, colorSecondary) end end - if props.color2 ~= nil then if type(props.color2) == "table" then SetVehicleCustomSecondaryColour(vehicle, props.color2[1], props.color2[2], props.color2[3]) @@ -1013,7 +1005,6 @@ function ESX.Game.SetVehicleProperties(vehicle, props) SetVehicleColours(vehicle, props.color1 or colorPrimary, props.color2) end end - if props.pearlescentColor ~= nil then SetVehicleExtraColours(vehicle, props.pearlescentColor, wheelColor) end From 9b0ffead471c6574d0c8998b61af17f10a5a8207 Mon Sep 17 00:00:00 2001 From: Muhammed Yaseen Date: Fri, 9 May 2025 08:48:44 +0530 Subject: [PATCH 3/5] Revamped GetVehicleProperties in compatible with the removal of customPrimay and secondary colors --- [core]/es_extended/client/functions.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 71ed4882..aa5f572e 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -805,14 +805,19 @@ function ESX.Game.GetVehicleProperties(vehicle) return end - local colorPrimary, colorSecondary = GetVehicleColours(vehicle) + local colorPrimary, colorSecondary = GetVehicleColours(vehicle) ---@type number | number[], number | number[] local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle) local hasCustomPrimaryColor = GetIsVehiclePrimaryColourCustom(vehicle) + local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle) local dashboardColor = GetVehicleDashboardColor(vehicle) local interiorColor = GetVehicleInteriorColour(vehicle) - local customPrimaryColor = nil + if hasCustomPrimaryColor then - customPrimaryColor = { GetVehicleCustomPrimaryColour(vehicle) } + colorPrimary = { GetVehicleCustomPrimaryColour(vehicle) } + end + + if hasCustomSecondaryColor then + colorSecondary = { GetVehicleCustomSecondaryColour(vehicle) } end local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle) @@ -821,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 @@ -879,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, From 30a13c572622896984b16bb09c06dd1377baa8b8 Mon Sep 17 00:00:00 2001 From: Muhammed Yaseen Date: Fri, 9 May 2025 08:54:35 +0530 Subject: [PATCH 4/5] Revert "Revamped GetVehicleProperties in compatible with the removal of customPrimay and secondary colors" This reverts commit 9b0ffead471c6574d0c8998b61af17f10a5a8207. --- [core]/es_extended/client/functions.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index aa5f572e..71ed4882 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -805,19 +805,14 @@ function ESX.Game.GetVehicleProperties(vehicle) return end - local colorPrimary, colorSecondary = GetVehicleColours(vehicle) ---@type number | number[], number | number[] + local colorPrimary, colorSecondary = GetVehicleColours(vehicle) local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle) local hasCustomPrimaryColor = GetIsVehiclePrimaryColourCustom(vehicle) - local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle) local dashboardColor = GetVehicleDashboardColor(vehicle) local interiorColor = GetVehicleInteriorColour(vehicle) - + local customPrimaryColor = nil if hasCustomPrimaryColor then - colorPrimary = { GetVehicleCustomPrimaryColour(vehicle) } - end - - if hasCustomSecondaryColor then - colorSecondary = { GetVehicleCustomSecondaryColour(vehicle) } + customPrimaryColor = { GetVehicleCustomPrimaryColour(vehicle) } end local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle) @@ -826,6 +821,12 @@ 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 @@ -878,6 +879,8 @@ function ESX.Game.GetVehicleProperties(vehicle) dirtLevel = ESX.Math.Round(GetVehicleDirtLevel(vehicle), 1), color1 = colorPrimary, color2 = colorSecondary, + customPrimaryColor = customPrimaryColor, + customSecondaryColor = customSecondaryColor, pearlescentColor = pearlescentColor, wheelColor = wheelColor, From 9582c31a910a7b3641938c829559da14c496402b Mon Sep 17 00:00:00 2001 From: Muhammed Yaseen Date: Fri, 9 May 2025 08:59:08 +0530 Subject: [PATCH 5/5] Revamped variable orders --- [core]/es_extended/client/functions.lua | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 71ed4882..02fe9772 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -805,14 +805,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) @@ -821,12 +825,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 @@ -879,8 +877,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,