Events
A list of available events to interact with cd_garage from your scripts.
Note
These events are entirely optional and can be triggered as needed to integrate cd_garage with your own scripts or custom systems.
Client
Client-Side Events
Defined with
RegisterNetEventin client files.Triggered using
TriggerEvent(if from client) orTriggerClientEvent(if from server).Run only on one player’s game client (the player’s PC).
Mileage
Sends a notification displaying the mileage of the vehicle you are in.
TriggerEvent('cd_garage:checkmileage')TriggerClientEvent('cd_garage:checkmileage', source)Impound Vehicle
Opens the impound UI. You can send a vehicle’s ID as the first argument; otherwise, it will automatically select the closest vehicle.
---@param vehicle number | entity The vehicle entity to be impounded.
---@example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)TriggerEvent('cd_garage:ImpoundVehicle', vehicle)TriggerClientEvent('cd_garage:ImpoundVehicle', source, vehicle)Transfer Vehicle
Transfers the vehicle you are currently sitting in to another player.
--- @param serverid number The server ID of the player to transfer the vehicle to.
--- @example
--- local serverid = 23TriggerEvent('cd_garage:TransferVehicle', serverid)Toggle Vehicle Lock
Toggles the lock state of the closest vehicle to the player.
TriggerEvent('cd_garage:ToggleVehicleLock')TriggerClientEvent('cd_garage:ToggleVehicleLock', source)Set Vehicle Locked
Locks a vehicle using the garage’s built-in key system. You must send the vehicle’s ID in the first argument.
--- @param vehicle number | entity The vehicle entity to lock.
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)TriggerEvent('cd_garage:SetVehicleLocked', vehicle)TriggerClientEvent('cd_garage:SetVehicleLocked', source, vehicle)Set Vehicle Unlocked
Unlocks a vehicle using the garage’s built-in key system. You must send the vehicle’s ID in the first argument.
--- @param vehicle number | entity The vehicle entity to unlock.
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)TriggerEvent('cd_garage:SetVehicleUnlocked', vehicle)TriggerClientEvent('cd_garage:SetVehicleUnlocked', source, vehicle)Update Garage Type
Updates the vehicle’s garage type in the database based on your current vehicle.
TriggerEvent('cd_garage:UpdateGarageType')TriggerClientEvent('cd_garage:UpdateGarageType', source)Impound Vehicle Directly
Impounds a vehicle directly using code without opening the impound UI. Sends detailed data such as the plate, impound location, vehicle properties, and retrieval status.
--- @field plate string The vehicle’s plate.
--- @field impound number The Impound ID from Config.ImpoundLocations.
--- @field props table The vehicle’s properties.
--- @field time number The time the vehicle was impounded.
--- @field description string The reason or description for the impound.
--- @field canretrive boolean Whether the vehicle can be retrieved by the owner.
--- @field vehicle number | entity The vehicle entity.TriggerEvent('cd_garage:ImpoundVehicle:Direct', {
plate = plate,
impound = impound,
props = props,
time = time,
description = description,
canretrive = canretrive,
vehicle = vehicle,
})TriggerClientEvent('cd_garage:ImpoundVehicle:Direct', source, {
plate = plate,
impound = impound,
props = props,
time = time,
description = description,
canretrive = canretrive,
vehicle = vehicle,
})Set Job Owned Vehicle
Marks the vehicle the player is currently sitting in as either a personal or society owned job vehicle. This event must be triggered while the player is inside the vehicle.
--- @param type string The ownership type: 'personal' or 'society'.
--- @@example
--- local type = 'personal'TriggerEvent('cd_garage:SetJobOwnedVehicle', type)TriggerClientEvent('cd_garage:SetJobOwnedVehicle', source, type)Open Property Garage
Opens the garage UI from a property script.
--- @param type string The garage type: 'quick' or 'inside'.
--- @param shell string | nil The shell type: can be nil, '10cargarage_shell', or '40cargarage_shell'.
--- @example
--- local type = 'quick'
--- local shell = nilTriggerEvent('cd_garage:PropertyGarage', 'quick', nil)TriggerClientEvent('cd_garage:PropertyGarage', source, 'quick', nil)Store Vehicle Property Garage
Stores the player's vehicle from a property script.
--- The arguments below must remain exactly as shown (1, false, false) and cannot be changed.TriggerEvent('cd_garage:StoreVehicle_Main', 1, false, false)TriggerClientEvent('cd_garage:StoreVehicle_Main', source, 1, false, false)Add Keys
Gives the player keys for a specific vehicle based on its plate.
-- @param plate string The vehicle’s plate. Example: "ABCD1234"
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
--- local plate = exports['cd_garage']:GetPlate(vehicle)TriggerEvent('cd_garage:AddKeys', plate)TriggerClientEvent('cd_garage:AddKeys', source, plate)Remove Keys
Removes the player's keys for a specific vehicle based on its plate.
-- @param plate string The vehicle’s plate. Example: "ABCD1234"
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
--- local plate = exports['cd_garage']:GetPlate(vehicle)TriggerEvent('cd_garage:RemoveKeys', plate)TriggerClientEvent('cd_garage:RemoveKeys', source, plate)Show Keys UI
Opens the vehicle keys UI for the player, displaying all vehicles they currently have keys for.
TriggerEvent('cd_garage:ShowKeys')TriggerClientEvent('cd_garage:ShowKeys', source)Server
Server-Side Events
Defined with
RegisterServerEventandAddEventHandlerin server files.Triggered using
TriggerEvent(if from server) orTriggerServerEvent(if from client).Run on the server, not on any individual player’s game client.
Save Mileage Timer
Saves the mileage data for all vehicles currently tracked by cd_garage. Typically used before a server restart.
TriggerClientEvent('cd_garage:SaveAllMiles', -1)Save Vehicle Damage Timer
Saves the damage data for all vehicles currently tracked by cd_garage. Typically used before a server restart.
TriggerClientEvent('cd_garage:SaveAllVehicleDamage', -1)Save Impound Timer
Saves all active impound timers to the database, ensuring impounded vehicle durations are correctly updated and persistent.
TriggerEvent('cd_garage:SaveImpoundTimers')Set Garage State
Updates the vehicle’s “in garage” status in the database.
--- @param plate string The vehicle’s license plate. Example: "ABCD1234"
--- @param state number The vehicle’s garage state. 0 = not in garage, 1 = in garage.
--- @example
--- local plate = "ABCD1234"
--- local state = 1TriggerEvent('cd_garage:SetGarageState', plate, state)Add Owned Keys
Used when adding an owned vehicle to a player’s garage. This ensures the new vehicle appears in the player’s keys UI.
--- @param plate string The vehicle’s plate. Example: "ABCD1234"
--- @param model number The vehicle’s model hash. Example: 127317925
--- @example
--- local plate = "ABCD1234"
--- local model = GetEntityModel(GetVehiclePedIsIn(PlayerPedId()))TriggerServerEvent('cd_garage:AddKeysOwnedVehicle', plate, model)TriggerEvent('cd_garage:AddKeysOwnedVehicle', plate, model, src)Add Persistent Vehicle
Used to mark a vehicle as persistent, allowing it to automatically save and respawn if it despawns while the server is running.
--- @param plate string The vehicle’s plate. Example: "ABCD1234"
--- @param netId number The vehicle’s network ID. Example: NetworkGetNetworkIdFromEntity(vehicle)
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
--- local plate = exports['cd_garage']:GetPlate(vehicle)
--- local netId = NetworkGetNetworkIdFromEntity(vehicle)TriggerServerEvent('cd_garage:AddPersistentVehicles', plate, netId)TriggerEvent('cd_garage:AddPersistentVehicles', plate, netId)Remove Persistent Vehicle
Used to remove a vehicle from the persistent system, preventing it from saving or respawning automatically.
--- @param plate string The vehicle’s plate. Example: "ABCD1234"
--- @example
--- local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
--- local plate = exports['cd_garage']:GetPlate(vehicle)TriggerServerEvent('cd_garage:RemovePersistentVehicles', plate)TriggerEvent('cd_garage:RemovePersistentVehicles', plate)Last updated
Was this helpful?

