overextended/ox_core

Vehicle parsing

thelindat opened this issue · 1 comments

Need a way to easily setup static vehicle data (vehicles.json), mostly for people adding custom vehicles.
Data was recently simplified, dropping some data that couldn't be easily automated, i.e.

"adder": {
  "bodytype": "supercar",
  "class": 7,
  "doors": 3,
  "make": "TRUFFADE",
  "name": "Adder",
  "price": 900000,
  "seats": 2,
  "type": "automobile",
  "weapons": false
}

was reduced to

"adder": {
  "class": 7,
  "make": "TRUFFADE",
  "name": "Adder",
  "seats": 2
}

Basically only storing data that has a native getter, and leaving false values as undefined.

  • GetEntityArchetypeName
  • GetVehicleClass
  • GetMakeNameFromVehicleModel
  • GetVehicleModelNumberOfSeats
  • DoesVehicleHaveWeapons

A pending PR to FiveM introduces a native for GET_ALL_VEHICLE_MODELS, which could be used to spawn each vehicle and generate all this data (including custom vehicles).

Resolved with 473055d.

Use setr ox:debug 1 to enable debug / development mode (currently only enables vehicle parser).
This may be unstable / laggy and requires vehicle models to load in, which means downloading streamed assets; if you have a lot of vehicles, this could be incredibly slow.

Ideally this parsing should work by parsing vehicles.meta and other such files, i.e. https://github.com/AvarianKnight/carexporter