Optional Features

This section explains how the built-in features work and, if needed, how to make them compatible with other resources. These optional features can be configured in [configs/config.lua].

Translate


Vehicles Data (vehicle names)

We will retrieve this data on ESX from the "vehicles" database table, as this is very common in ESX servers. This data will be used to display information in the garage UIs.

If Config.VehiclesData is enabled, the script will fetch the vehicle display name, vehicle class, vehicle price, and the garage tax amount (if Config.VehiclesData.garage_tax is enabled) from the "vehicles" database table. This is the easiest way to configure everything for your server's needs.

Multiple "vehicles" Database Tables

Some servers use multiple "vehicles" database tables for things like donator or emergency vehicles. To accommodate this, simply add the names of these tables to Config.VehiclesData.VehicleDatabase_TableNames in the config.lua file.


Boat & Air garages

How Do Boat & Air Garages Work?

When a player buys a boat or aircraft, you'll need to update the garage_type field in the database for that vehicle. If you're not using boat or air vehicles on your server, you can ignore this step since the default value for garage_type is set to "car."

Compatible Code Snippets Provided by Codesign

On our Garage Resource Integration page, we provide photos, customized code snippets, and precise line modifications for full compatibility with ESX, QBCore and Paid Resources.

Click here for ESX.

Click here for QBCore.

Click here for Paid Resources.

Ideally, the garage_type should be set in the same SQL query that adds the vehicle to the database when it's purchased.

The garage_type can only have one of three values: 'car', 'boat', or 'air'. These values must be strings.

For example, to make a boat appear in the boat garage, you need to edit the SQL query in your vehicle shop to insert 'boat' into the garage_type column in the owned_vehicles / player_vehicles database table for that vehicle. The same applies for air vehicles.

You don't need to do this for cars or bikes, as the default value for this column in the database is always set to 'car'.


Private Garages

How Do Private Garages Work?

Private garages operate like public garages but can be placed anywhere using a chat command. Only the player who purchased them can see or use them. In the config.lua, you can enable specific jobs, like real estate, to create and sell private garages to players.


Property Garages

How Do Property Garages Work?

If you use a paid property resource, it's best to contact the resource developer for assistance with property garages, as the Codesign Team doesn't have access to those resources without the developer’s permission. However, we've made it very simple for you to integrate property garages into your property resource.

Do You Use QBCore?

No changes are needed—everything is already pre-configured!

How do I choose the type of garage to open:

Choose either 'quick' or 'inside' in the 1st argument.

Choose the shell to enter if you use the inside garage:

Replace nil with '10cargarage_shell' or '40cargarage_shell' in the 2nd argument.

TriggerEvent('cd_garage:PropertyGarage', 'quick', nil)

Fake Plates

How Do Fake Plates Work?

In the config.lua, you can set the spawn name for the usable fake plate item. To use it, stand near a vehicle you own, use the item, and enter the new plate in the text box. The fake plate will be applied to your vehicle. When the vehicle is stored in the garage, the fake plate will be removed. You or specific jobs (like the police) can also remove the fake plate using a chat command.

Built-in Vehicle Keys Required!

This is only pre-configured for our built-in keys system. It won’t work with other key resources by default unless you trigger an event or export to give keys after a fake plate has been added.


Vehicle Keys

How Do Vehicle Keys Work?

If you're using the built-in vehicle keys system, you'll need to trigger an event every time a vehicle is spawned in non-Codesign resources, such as the /car command, vehicle shops, or civilian job vehicles.

Script Conflicts!

If you're using our built-in key system, you must stop or remove any other key scripts. Be sure to double-check that they are fully stopped, as they might still start automatically if listed as a dependency, even if you've removed them from the server start config.

Compatible Code Snippets Provided by Codesign

On our Garage Resource Integration page, we provide photos, customized code snippets, and precise line modifications for full compatibility with ESX, QBCore and Paid Resources.

Click here for ESX.

Click here for QBCore.

Click here for Paid Resources.

Copy the code snippet below and paste it into any resource where you want the player to receive vehicle keys.

Notes:

  • This event must be placed after the vehicle has been created or spawned.

  • If the vehicle’s plate changes after spawning, place the event below that code.

You need to make sure vehicle is defined.
TriggerEvent('cd_garage:AddKeys', exports['cd_garage']:GetPlate(vehicle))

Persistent Vehicles

How Do Persistent Vehicles Work?

Our persistent vehicle feature automatically saves and respawns any vehicles that despawn, whether you're still in the server or after re-logging. By default, only vehicles spawned through our garage will be persistent, but you can make additional vehicles persistent using the events listed below. A vehicle’s position is saved when it remains stationary for more than 5 seconds. Note that vehicles will not save or respawn after a server restart.

Possible Modifications Required!

If you use this feature, you must add the event below to remove a persistent vehicle in external resources (e.g., in your /dv chat command, external impound resources, or when the plate changes). Otherwise, the vehicle will respawn.

Compatible Code Snippets Provided by Codesign

On our Garage Resource Integration page, we provide photos, customized code snippets, and precise line modifications for full compatibility with ESX, QBCore and Paid Resources.

Click here for ESX.

Click here for QBCore.

This should be triggered when a vehicle is spawned that you want to be persistent. The 1st argument is the vehicle's plate and the 2nd argument is the vehicle's network id.
TriggerServerEvent('cd_garage:AddPersistentVehicles', exports['cd_garage']:GetPlate(vehicle), NetworkGetNetworkIdFromEntity(vehicle))

Job Garages

How Do Job Garages Work?

We offer 3 options for job garages, with each location configurable to use a different method. Each method needs to be implemented differently.

This garage script does not include a vehicle shop, so if you choose the Personal Owned or Society Owned methods, you'll need to set that up separately.

Compatible Code Snippets Provided by Codesign

On our Garage Resource Integration page, we provide photos, customized code snippets, and precise line modifications for full compatibility with ESX, QBCore and Paid Resources.

Click here for ESX.

Do you use QBCore? By default, QBCore uses the regular job garage method. So, unfortunately, we don't have any guides for setting up personal or society garages.

What Are Regular Job Vehicles?

These are vehicles that are spawned in and not owned by anyone.

To configure them, add the vehicles of your choice to the Config.JobVehicles.RegularMethod table in the config. Each job has its own selection of vehicles that only players with that job can use.


Gang Garages

How Do Gang Garages Work?

The main difference between job garages and gang garages is that when a player stores their personal vehicle in a gang garage, any member of that gang can take it out and use it until the owner retrieves it and puts it back in their personal garage. However, other gang members cannot store your vehicle in their personal garages.

Disabled on ESX!

Gang garages can only be used on QBCore, as gangs in ESX are considered standard jobs. For ESX, you should use the job garage for gang-related vehicles.


Garage Slots

How Do Garage Slots Work?

Our garage slots feature allows players to manage the number of vehicles they can own by limiting garage slots. By default, there are no limits, but you can enable restrictions and control how many cars each player can store. Players can purchase additional slots through in-game commands, and only authorized jobs, like car dealers, can sell these extra garage slots. Pricing for extra slots can be customized, and players can easily check their available garage slots using a designated chat command.

This code should be placed server-side within your vehicle shop resource. It ensures that when a player tries to buy a new car, the system checks whether they have enough available garage slots to store the new vehicle before allowing the purchase.

Usage Example for Garage Slots (Server-Side Only):

if exports['cd_garage']:GetGarageCount(source, 'car') + 1 <= exports['cd_garage']:GetGarageLimit(source) then
    print('allow purchase') -- Allow the purchase if the new car will fit within the limit
else
    print('garage limit reached') -- Deny the purchase if the new car will exceed the limit
end

In this example:

  • GetGarageCount(source, 'car'): Retrieves the number of cars the player currently has in their garage.

  • GetGarageLimit(source): Retrieves the maximum number of cars the player can store based on their garage slots.

  • The code checks if the player’s current vehicle count plus the new car (hence + 1) is still within the allowed garage slot limit. If it is, the purchase is allowed; otherwise, it’s denied with the message "garage limit reached."


Changing Garage Names

To change the names of the garages (e.g., from "A" to "Legion"), you need to configure the Garage_ID variable in the Config.Locations section of the configs/config.lua file. The script will automatically handle the necessary database updates for you.


Garage Phone Apps

How Do Garage Phone Apps Work?

By default, your phone's garage app may not be compatible with cd_garage. However, we provide code snippets for compatibility in our Garage Resource Integration to help resolve this issue.


Custom vehicle logos

Credits to @Baby Amnesia for making this tutorial.

Last updated

Logo

Codesign Software © All rights reserved