Skip to content

Conversation

gtolontop
Copy link

Description

This PR implements a complete Vehicle Identification Number (VIN) system for ESX vehicles, as requested in issue #1638. Each vehicle now has a unique 17-character VIN that persists across plate changes and provides a permanent identifier for vehicles.


Motivation

Currently, vehicles are only identified by their license plate, which creates limitations for advanced roleplay mechanics. A VIN system enables:

  • Vehicle history tracking independent of plate changes
  • Plate swapping/changing mechanics
  • Law enforcement investigations
  • Insurance and ownership verification systems
  • Better vehicle persistence and tracking

Implementation Details

  • Database: Added vin column (VARCHAR(17) UNIQUE) to owned_vehicles table with index
  • Automatic Generation: Vehicles without VIN automatically receive a unique 17-character alphanumeric VIN
  • Vehicle Class Enhancement:
    • Added vin field to CVehicleData
    • Added getVin() method to retrieve VIN
    • VIN stored in entity state for network sync
  • Utility Functions:
    • ESX.GenerateVIN() - Generates unique VIN with database collision check
    • ESX.GetExtendedVehicleFromVIN(vin) - Find vehicle by VIN
  • Admin Command: /getvehiclevin [plate] for testing and debugging
  • Backward Compatibility: Existing vehicles receive VIN on first spawn

Usage Example

-- Get vehicle VIN
local xVehicle = ESX.GetExtendedVehicleFromPlate("ABC123")
if xVehicle then
    local vin = xVehicle:getVin()
    print("Vehicle VIN: " .. vin) -- Output: 1ES1234567890ABCD
end

-- Find vehicle by VIN
local xVehicle = ESX.GetExtendedVehicleFromVIN("1ES1234567890ABCD")
if xVehicle then
    local plate = xVehicle:getPlate()
    print("Vehicle with this VIN has plate: " .. plate)
end

Admin command usage:
/getvehiclevin ABC123
Shows notification: Vehicle VIN: g1ES1234567890ABCDs


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.

…erve model names in VIN generation (server/classes/vehicle)
…X types (remove car/truck/helicopter, add quadbike/amphibious/trailer)
@Kenshiin13 Kenshiin13 changed the base branch from main to dev August 30, 2025 19:08
@Kenshiin13 Kenshiin13 marked this pull request as draft August 31, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant