Garages

I can't make my script "compatible" with all the Garages because there's more than 50 (no cap, I just search it on Fivem releases).

So this is just a little "guide" to help you make the script "compatible" with your Garage script, of course all column names will vary from script to script.

Read Me

  • First thing you need to do, BUY A VEHICLE in your test server and verify your server console, if you don't have ANY error and you can save and retrieve your vehicle from your garage then you are OK, you don't need to do anything else.

  • If you server console looks something like this:

This is just an EXAMPLE
  • Let's read what the error is telling us:

Error: av_vehicleshop was unable to execute a query
Query: INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-- A LOT OF INFO THAT WE DON'T CARE ABOUT ----
Unknown column 'garage' in 'field list'
  • The script tried to save the vehicle into your player_vehicles table (or owned_vehicles if using ESX) BUT the column garage does not exist in your table... oh wait, why!? Ah yes, because I'm using a different Garage script that altered my table and created/modified the default fields, let's fix it!

  • Go to your Database > player_vehicles (or owned_vehicles if using ESX), check your columns names:

I'm using heidi sql, your DB might look different if using phpmysql, etc
  • The error was about an unknown column named 'garage'.... oh wait! there's no garage column BUT we have a column named parking that my Garage script uses to store the garage name where the vehicle is stored.

  • What should we do now? We need to change the query in av_vehicleshop/server/editable/buy.lua

  • Here you will find 2 queries, one for QB and one for ESX, modify the one that belongs to the Framework you are using, for this example I'm using QBCore so I will modify line 10 (for ESX is line 22):

  • Once we have identified what query we need to modify and what's the column giving us the "error" we need to replace it.

-- We modify the old query:
MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {

-- Replacing the garage field with parking:
MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, parking, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
  • Save the changes, restart av_vehicleshop and buy the vehicle again...

  • Did u got another column error? Let's repeat the steps we made for garage/parking but with this new column giving the error.

Last updated