Skip to content

Refactored Set vehicle Properties#1637

Merged
Zykem merged 5 commits intoesx-framework:devfrom
l2rhydra:main
May 22, 2025
Merged

Refactored Set vehicle Properties#1637
Zykem merged 5 commits intoesx-framework:devfrom
l2rhydra:main

Conversation

@l2rhydra
Copy link
Copy Markdown
Contributor

@l2rhydra l2rhydra commented May 9, 2025

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

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@github-project-automation github-project-automation bot moved this to 🆕 To be Discussed in ESX Roadmap May 9, 2025
@l2rhydra l2rhydra changed the title Refatored Set vehicle Properties Refactored Set vehicle Properties May 9, 2025
@l2rhydra l2rhydra changed the base branch from main to dev May 9, 2025 02:39
@github-project-automation github-project-automation bot moved this from 🆕 To be Discussed to In-Development in ESX Roadmap May 9, 2025
@l2rhydra l2rhydra requested a review from Zykem May 9, 2025 04:11
Copy link
Copy Markdown
Contributor

@Zykem Zykem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@github-project-automation github-project-automation bot moved this from In-Development to Ready for Next Update in ESX Roadmap May 9, 2025
Copy link
Copy Markdown

@SophiaDLL SophiaDLL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look's Good.

@Zykem
Copy link
Copy Markdown
Contributor

Zykem commented May 22, 2025

esx-framework/esx-legacy-documentation@bc84ae3

Documentation update regarding your Pull Request.

@Zykem Zykem merged commit d948b1b into esx-framework:dev May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Next Update

Development

Successfully merging this pull request may close these issues.

4 participants