How to add cars to QBCore, Qbox and ESX
A car can spawn by command as soon as its resource runs. To sell it at a dealership, store it in a garage and give players keys, your framework also needs it in its own vehicle list. Here is where that list lives in QBCore, Qbox and ESX.
1Install the car first
Put the car\'s resource in your
resourcesfolder andensureit, then check it spawns with/car <spawn code>. The install guide covers that part; if it won\'t spawn, see car not spawning.2QBCore: shared/vehicles.lua
Add an entry to
qb-core/shared/vehicles.luawith themodel(the spawn code),name,brand,price,category,type('automobile'for cars,'bike'for bikes) andshop— the dealership that sells it, such as'pdm'. Thecategoryhas to be one that shop lists in qb-vehicleshop\'s config, or it won\'t show. Restart the server afterwards: shared files are read when it starts.3Qbox: qbx_core and qbx_vehicleshop
Qbox keeps the list in
qbx_core/shared/vehicles.lua, keyed by model:mycar = { name, brand, model, price, category, type, hash }, wherehashis the model name in backticks. Which dealership sells it is set inqbx_vehicleshop/config/shared.lua: by model undervehicles.models, by category undervehicles.categories, or thedefaultshop — and that shop\'s owncategoriesmust include the car\'s category.4ESX: the vehicles table
ESX\'s vehicle shop reads the database. Add a row to the
vehiclestable withname,model(the spawn code),priceandcategory, where the category exists invehicle_categories— for exampleINSERT INTO vehicles (name, model, price, category) VALUES ('My Car', 'mycar', 50000, 'sports');. Restart the vehicle shop afterwards.5Garages, keys and ownership
Bought cars are saved per player —
player_vehicleson QBCore and Qbox,owned_vehicleson ESX — and the keys script hands over keys on purchase. If a car spawned by command has no keys, use your keys script\'s give-keys command; that\'s normal for cars that weren\'t bought.6Name shows as NULL or the wrong name
The garage reads the car\'s display name from a text entry for its
gameName. Without one you see "NULL" or the raw model name. A client script withAddTextEntry('MYCAR', 'My Car')fixes it — the Vehicle Registrar writes that line and the QBCore, Qbox and ESX entries above straight from the car\'svehicles.meta.
Every GXD vehicle works on QBCore, Qbox, ESX and standalone, and its spawn code is on its page. Start with the free cars if you want to test the steps first.
