Commands & Exports

This section lists all available commands, exports, and events included in the script. You’ll find client-side, server-side, and shared functions designed to help developers integrate, extend, or interact with the system easily within their own scripts or frameworks.


Commands

This section lists all available commands included in the script. Each command is designed to simplify administration, player interaction, or debugging tasks. You’ll find detailed descriptions, usage examples, and permission requirements to help you manage and customize your server efficiently.

Command
Description

/mdv

Alternate command to /dv, this removes the closest car and sends it to impound.

/mdvall

Command that sends all OUT cars to impound.

/repairvehicle

Repair the nearby vehicle or the one you are currently sitting on.

/addJobVehicle

Add the car you are in to a job garage.

/deleteJobVehicle

Remove the work vehicle from a certain garage.

/creategaragemenu

Command to create garages, you must have the specific job.

/garagemenu

Command to modify the garage, only if you own the garage where you are.

/impound

Command to send cars to an impound, have the specific job.

/givecar [id] [model] [plate]

Command that will send a car to the selected player.

/giveboat [id] [model] [plate]

Command that will send a boat to the selected player.

/giveplane [id] [model] [plate]

Command that will send a plane to the selected player.


Client Exports

This section provides all available client exports for the script. These functions allow you to interact directly with the system from the client side, enabling custom features, UI interactions, and integrations with other resources. Each export includes a short description and usage example for easy implementation.

RepairSpecificVehicle

The RepairSpecificVehicle export allows you to repair a specific vehicle by specifying its plate. This is useful for targeted vehicle repairs, ensuring that only the intended vehicle is fixed.


How to Use

To repair a specific vehicle, use the following code:

local plate = "ABC123" -- Replace with the actual plate of the vehicle you want to repair
exports['qs-advancedgarages']:RepairSpecificVehicle(plate)
print("Vehicle with plate " .. plate .. " has been repaired.")

This export takes the plate of the vehicle as an argument. Use it in your scripts to repair vehicles based on their unique plate identifiers, ensuring accurate maintenance and gameplay logic.

RepairNearestVehicle

The RepairNearestVehicle export allows you to repair the nearest vehicle to the player. This is ideal for quick repairs without needing to specify a vehicle plate.


How to Use

To repair the nearest vehicle, use the following code:

exports['qs-advancedgarages']:RepairNearestVehicle()
print("The nearest vehicle has been repaired.")

This export does not require any parameters. It automatically identifies and repairs the closest vehicle to the player, making it a convenient solution for general vehicle maintenance scenarios.

ImpoundVehicle

The ImpoundVehicle export allows you to send the nearest vehicle to an impound directly from the client side. This is useful for managing abandoned or illegally parked vehicles in a streamlined way.


How to Use

To impound the nearest vehicle, use the following code:

exports['qs-advancedgarages']:ImpoundVehicle()
print("The nearest vehicle has been impounded.")

This export requires no additional parameters. It identifies the closest vehicle to the player and moves it to the impound, ensuring efficient handling of vehicles in the game environment.


Server Exports

This section provides all available server exports for the script. These functions allow developers to interact with the system from the server side, manage data, trigger actions, and integrate with other resources. Each export includes a clear description and a practical example to simplify its implementation.

impound

The impound export allows you to impound a specific vehicle by providing its license plate. This is particularly useful for server-side scripts or administrative actions that require targeting a particular vehicle.


How to Use

To impound a vehicle by its plate, use the following code:

local plate = "ABC123" -- Replace with the specific license plate
exports['qs-advancedgarages']:impound(plate)
print("The vehicle with plate " .. plate .. " has been impounded.")

This export requires the vehicle's license plate as an argument and will send the targeted vehicle to the impound. Use this feature for precise vehicle management and enforcement.

GiveVehicle

The GiveVehicle export is used to manually spawn and assign a vehicle to a player, either with a custom license plate or a randomly generated one. This export is typically used in administrative tools, staff menus, or scripted rewards that provide vehicles to players directly.


How to Use

To give a vehicle to a player, use the following code:

lexports['qs-advancedgarages']:GiveVehicle(source, {'playerId', 'vehicleModel', 'plate'}, 'vehicle')
  • To use a random plate, just omit the plate:

exports['qs-advancedgarages']:GiveVehicle(source, {'playerId', 'vehicleModel'}, 'vehicle')

Parameters

  • 'playerId': The target player's server ID.

  • 'vehicleModel': The spawn name of the vehicle (e.g., "sultan").

  • 'plate' (optional): Custom license plate (can include multiple parts).

  • 'vehicle': Type of entity — must be "vehicle", "plane" or "boat".

This export is ideal for admin tools, vehicle rewards, or staff menus.

RepairNearestVehicle

The RepairNearestVehicle export allows you to repair the nearest vehicle to the player. This is ideal for quick repairs without needing to specify a vehicle plate.


How to Use

To repair the nearest vehicle, use the following code:

exports['qs-advancedgarages']:RepairNearestVehicle()
print("The nearest vehicle has been repaired.")

This export does not require any parameters. It automatically identifies and repairs the closest vehicle to the player, making it a convenient solution for general vehicle maintenance scenarios.

SpawnVehicle

The SpawnVehicle export allows you to spawn a vehicle programmatically with persistence while ensuring it matches the server's vehicle data. This is useful for scenarios where vehicles need to be spawned externally but still retain their database-linked attributes.


How to Use

To spawn a vehicle with persistence, use the following code:

-- Example values for required parameters
local vehicleId = 1                 -- ID from the player_vehicles or owned_vehicles table
local ownerIdentifier = "steam:xyz" -- Player's unique identifier
local vehicleType = "car"           -- Type of vehicle: 'vehicle', 'boat', or 'plane'
local spawnCoords = vector4(215.2, -810.2, 30.7, 90.0) -- Coordinates to spawn the vehicle
local vehicleProps = {color1 = 0, color2 = 1}          -- Custom vehicle properties (mods)
local playerSource = 1              -- Player's server-side source ID
local warpIntoVehicle = true        -- Whether the player should spawn inside the vehicle

-- Spawn the vehicle
exports['qs-advancedgarages']:SpawnVehicle(vehicleId, ownerIdentifier, vehicleType, spawnCoords, vehicleProps, playerSource, warpIntoVehicle)

print("Vehicle spawned with persistence for player " .. ownerIdentifier)

Explanation of Parameters

  • id: Unique ID of the vehicle from the database (e.g., player_vehicle > column id).

  • owner: The player's identifier (Steam, Discord, etc.).

  • vType: Type of vehicle, such as vehicle, boat, or plane.

  • coords: Coordinates and heading where the vehicle will spawn.

  • props: Vehicle modifications or properties retrieved from the database.

  • source: Player's server source ID.

  • warp: Boolean to decide if the player spawns directly inside the vehicle.

This export ensures that the spawned vehicle integrates seamlessly with the persistence system and retains all database-defined characteristics.

setVehicleToPersistent

The setVehicleToPersistent export allows you to assign persistence to a vehicle spawned externally from your server's vehicle shops or other spawning systems. This ensures that the vehicle remains active within the advanced garage system.


How to Use

To set a vehicle as persistent, use the following code:

-- Example: Assigning persistence to a vehicle
local vehicleNetId = NetworkGetNetworkIdFromEntity(vehicleEntity) -- Get the netId of the vehicle entity

-- Make the vehicle persistent
exports['qs-advancedgarages']:setVehicleToPersistent(vehicleNetId)

print("Vehicle with netId " .. vehicleNetId .. " is now persistent.")

This export is particularly useful for integrating third-party vehicle shops or custom spawn systems into the Quasar Advanced Garages persistence framework. It ensures that any externally spawned vehicle behaves as if it were managed directly by the garage system, including saving and tracking its state.

removeVehicleFromPersistent

The removeVehicleFromPersistent export is used to remove the persistence of one or more vehicles. This is particularly helpful when vehicles need to be removed from the map after specific native events or when they no longer need to be tracked by the garage system.


How to Use

To remove persistence, use the following code:

-- Example: Removing persistence for a single vehicle
exports['qs-advancedgarages']:removeVehicleFromPersistent("ABC123")

-- Example: Removing persistence for multiple vehicles
exports['qs-advancedgarages']:removeVehicleFromPersistent("ABC123", "XYZ789", "LMN456")

print("Vehicles removed from persistence.")

This export requires one or more license plate strings as arguments. Once called, the specified vehicles will no longer be managed by the persistence system and can be removed from the map without returning automatically. This is useful for administrative purposes or specific gameplay scenarios.

updateVehiclePlate

The updateVehiclePlate export is designed to change the license plate of a vehicle dynamically. This is particularly useful for integrating with custom assets or systems that allow players to modify vehicle plates.


How to Use

To update a vehicle's license plate, use the following code:

local currentPlate = "ABC123" -- Current vehicle plate
local newPlate = "NEWPLT"    -- New plate to assign
exports['qs-advancedgarages']:updateVehiclePlate(currentPlate, newPlate)

print("Plate updated from " .. currentPlate .. " to " .. newPlate)

Example

Here is an example of how you might implement this functionality with a command:

RegisterCommand('changeplate', function(source)
    local playerPed = GetPlayerPed(source)
    local vehicle = GetVehiclePedIsIn(playerPed, false)
    
    if not DoesEntityExist(vehicle) then
        print("Player is not in a vehicle.")
        return
    end
    
    local currentPlate = GetVehicleNumberPlateText(vehicle)
    local newPlate = "PEPERONI" -- Example new plate
    
    exports['qs-advancedgarages']:updateVehiclePlate(currentPlate, newPlate)
    print("Plate successfully updated to " .. newPlate)
end, false)

Explanation

The export requires two parameters:

  • plate: The current license plate of the vehicle (string).

  • newPlate: The new license plate to assign to the vehicle (string).

Once executed, the garage system will instantly recognize the new plate, ensuring seamless integration with persistence systems and preventing conflicts with other assets.

updatePersistentVehicleProps

The updatePersistentVehicleProps export allows you to dynamically update the stored properties of a persisted vehicle in your garage system. This is especially useful when applying changes such as model, modifications, or metadata without needing to respawn the vehicle or edit the database manually.


How to Use

To update a persisted vehicle’s properties, use the following syntax:

local success = exports['qs-advancedgarages']:updatePersistentVehicleProps('PLATE', {
    model = 't20',
})

This will search for the vehicle with plate "PLATE" and update its stored model to "t20".


Example Usage

Here is an example of how you might implement this functionality with a command:

RegisterCommand('changemodel', function(source)
    local playerPed = GetPlayerPed(source)
    local vehicle = GetVehiclePedIsIn(playerPed, false)

    if not DoesEntityExist(vehicle) then
        print("Player is not in a vehicle.")
        return
    end

    local plate = GetVehicleNumberPlateText(vehicle)
    local success = exports['qs-advancedgarages']:updatePersistentVehicleProps(plate, {
        model = 't20',
    })

    if success then
        print("Vehicle model updated successfully in database.")
    else
        print("Failed to update vehicle model.")
    end
end, false)

Explanation

  • plate (string): The current plate of the vehicle to be updated.

  • props (table): A table of properties to be updated (e.g., model, engineHealth, mods, etc.).