Refactored Set vehicle Properties#1637
Merged
Zykem merged 5 commits intoesx-framework:devfrom May 22, 2025
Merged
Conversation
Zykem
requested changes
May 9, 2025
…mPrimay and secondary colors
…of customPrimay and secondary colors" This reverts commit 9b0ffea.
Contributor
|
esx-framework/esx-legacy-documentation@bc84ae3 Documentation update regarding your Pull Request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enhances vehicle color compatibility by allowing props.color1 and props.color2 to accept RGB table values (e.g., {255, 255, 255}), in addition to the existing integer-based color indexes. This update ensures compatibility with scripts that utilize RGB values for vehicle customization.
Motivation
Currently, using RGB tables (e.g., via mechanic menus or valet services) causes a runtime error because ESX.Game.SetVehicleProperties expects a number rather than a table. This change ensures a seamless experience for servers and scripts using RGB color customization, preventing native call failures and improving script robustness.
Implementation Details
Checks if props.color1 or props.color2 is a table.
If so, it uses SetVehicleCustomPrimaryColour or SetVehicleCustomSecondaryColour respectively with the RGB values.
If not, it falls back to SetVehicleColours with default primary/secondary values to maintain backward compatibility.
Usage Example
-- Example using RGB table
props = {
color1 = {255, 0, 0}, -- Red (RGB)
color2 = {0, 0, 255}, -- Blue (RGB)
}
-- Example using GTA color index
props = {
color1 = 1, -- Graphite
color2 = 64, -- Blue
}
props.color1 and props.color2 can be either:
An RGB table, e.g. {255, 255, 255}
A GTA default color index, e.g. 1
This ensures full compatibility with both modern and legacy vehicle color formats.
PR Checklist