Add cars to the FiveM vehicle shop (ESX vehicles table, QBCore, QBox)

How to add a car to a dealership: the ESX vehicles and vehicle_categories tables, QBCore and QBox shared vehicles.lua entries, and why a car shows up with no price.

Typical symptoms:

text
The addon car works with /car, but the dealership does not sell it. Or it shows with no name, no price, or in the wrong category.

A dealership sells what is listed in its data, not what exists in the game. Adding a car takes two steps: the model has to be streamed to the game, then it has to be listed in the data your framework uses. This article covers the second step for ESX, QBCore and QBox.

Step one: the model must be streamed

If the model is not loaded, the dealership cannot show it, and a purchase spawns nothing. Add the car as a resource first, and check it works in game:

text
/car mycar

Use the spawn name, which comes from the vehicles.meta of the car. If /car fails, fix that before touching the shop, see adding addon cars.

ESX: the vehicles table

The ESX dealership reads two SQL tables. vehicle_categories holds the categories shown in the shop menu, and vehicles holds the cars.

sql
DESCRIBE vehicle_categories;
DESCRIBE vehicles;

In a standard ESX Legacy database they look like this:

Table Columns
vehicle_categories name, label
vehicles name, model, price, category

Add a category if you need a new one:

sql
INSERT INTO vehicle_categories (name, label) VALUES ('mycars', 'My cars');

Then add the car:

sql
INSERT INTO vehicles (name, model, price, category)
VALUES ('My Car', 'mycar', 85000, 'mycars');
  • name is the label shown in the shop.
  • model is the spawn name, as in /car. Lowercase, exact.
  • price is a whole number.
  • category must match the name of a row in vehicle_categories, or the car does not appear in any category.

Restart the dealership resource, or the whole shop, so it reads the table again. Your column list can differ if you use a customised vehicle shop, so trust DESCRIBE over this table.

Tip: to see what a working car looks like, copy the values of a row that is already in the shop with SELECT * FROM vehicles LIMIT 5; and edit them.

QBCore: shared/vehicles.lua

QBCore keeps its vehicle list in a Lua file, qb-core/shared/vehicles.lua. Each entry is a car:

lua
['mycar'] = {
    model = 'mycar',
    name = 'My Car',
    brand = 'Mic',
    price = 85000,
    category = 'sports',
    categoryLabel = 'Sports',
    hash = `mycar`,
    shop = 'pdm',
},

The fields:

  • model: the spawn name, same as the table key.
  • name and brand: what the shop displays.
  • price: the sale price.
  • category and categoryLabel: the group in the menu.
  • hash: the model hash. The backtick form computes it for you.
  • shop: the id of the dealership that sells it, for example the default one. A shop name that does not exist means no shop sells the car.

The exact layout depends on the version of qb-core. Some versions use a table keyed by the model, others a plain list. Open your own file and copy a neighbouring entry, then change the values, so the structure always matches.

After editing, restart qb-core and the dealership resource. Restarting the core on a live server disconnects players in some setups, so do it at a quiet time, or restart the whole server.

QBox: qbx_core shared vehicles

QBox keeps vehicles in its own core, qbx_core/shared/vehicles.lua. The idea is the same as on QBCore: an entry with the model, name, brand, price, category and shop. QBox changes its data layout between releases, so open the file and copy an entry that already works on your version, then edit it.

Restart qbx_core and your dealership. Do not run a separate qb-core folder next to it, see converting QBCore scripts to QBox.

Dealership scripts with their own config

Not every dealership uses the framework list. Some read their own config file or a database table, and the vehicles table or the shared file is ignored. Check the script's config for a vehicle list first. If it has one, add the car there as well.

Name, price and category problems

The car shows no name. The name field is empty, or the dealership uses the game's display name. A display name in game comes from AddTextEntry with the model's gameName in vehicles.meta. Without it the shop can show NULL or the model. Set the label in your data.

A car that costs 0 or is free. The price is missing or not a number. Remove quotes around it.

The category does not show. On ESX, the category value has no row in vehicle_categories. On QBCore the category label is missing, or the shop filters by a category it does not know.

Wrong spawn name. Mycar and mycar are not the same in data lookups. Use the name exactly as defined, in lowercase.

Bought, but no car. The purchase worked and the spawn did not. The model is not streamed on the client, or the plate and owner are not saved. Check the console and the database, see the garage tables.

Handling and performance of addon cars

An added car with bad handling or a heavy model hurts the whole server. Check the handling before selling it, edit the vehicle handling, and test the model for texture memory, see oversized assets.

Add many cars at once

For a pack of cars, a loop in SQL saves time on ESX. Write the rows in one statement:

sql
INSERT INTO vehicles (name, model, price, category) VALUES
('Car A', 'cara', 60000, 'mycars'),
('Car B', 'carb', 75000, 'mycars'),
('Car C', 'carc', 90000, 'mycars');

On QBCore and QBox, paste the entries one after another in the Lua file, with a comma after each.

Checklist

Symptom Fix
Car works with /car but is not sold Add it to the vehicles table, or shared/vehicles.lua
Car missing from a category on ESX The category must match a name in vehicle_categories
No name or price shown Fill name and price, with the price as a number
Nothing sells the car on QBCore or QBox Check the shop value matches a dealership
Purchase spawns nothing The model is not streamed: fix the addon car first
Edited data has no effect Restart the data resource and the dealership
Lua file errors after editing Check commas and braces around your new entry

Quick answers

Why is my addon car not in the dealership?

The shop only lists what is in its data: the vehicles table on ESX, or shared/vehicles.lua on QBCore and QBox. Adding the car to the server stream is a separate step, and both are needed.

What is the model name I put in the table?

The spawn name of the vehicle, the one used in /car, which is defined in the vehicle's vehicles.meta. It must match exactly, in lowercase.

Do I need to restart the server after adding a car?

Restart the resource that holds the data, and the dealership script. On ESX the shop usually reads the table when it starts, so restarting it is enough.

Scripts that skip this problem

Advanced BoostingTablet-driven vehicle boosting: contracts from class D to S+, crews and a live queue.View script →Chameleon Paints82 colour-shifting chameleon paints in one click-to-apply menu.View script →Shop CreatorBuild a shop in under a minute — owners, employees, vaults and robberies included.View script →

Keep reading