# Server Exports

### getAllGarages

```lua
local garages = exports["vms_garagesv2"]:getAllGarages()
```

***

### getAllImpounds

```lua
local impounds = exports["vms_garagesv2"]:getAllImpounds()
```

***

### towVehicle

Towing the vehicle

```lua
---@param {*netId: number}: Vehicle ID or Network ID of entity
---@param {*plate: string}: License plate number
---@param {*impoundId: string}: Impound ID (by default are 'Impound1'/'ImpoundBoat'/'ImpoundPlane'/'ImpoundHeli'/'ImpoundPolice')
---@param {fine: string}: Towing fine title [Not required]
---@param {fine_amount: number}: Towing fine amount [Not required]
---@param {*towedBy: string}: Name of who towed
exports["vms_garagesv2"]:towVehicle(
    netId,
    plate,
    impoundId,
    fine,
    fine_amount,
    towedBy
)
```

***

### giveVehicle

Adding vehicles using export, application for example admin menu.\
After adding, the vehicle will go to the impound matching for the selected type.

```lua
---@param {source: number or nil}: ID of the player using export or nil
---@param {owner: number or string}: vehicle owner - player id or job name for company
---@param {type: string}: vehicle/boat/plane/helicopter (it must be a key from Config.VehicleTypes)
---@param {model: string}: model name of vehicle
---@param {plate: string}: license plate (Max 8 characters, special characters cannot be used!)
exports["vms_garagesv2"]:giveVehicle(
    source,
    owner,
    type,
    model,
    plate
)
```

***

### deleteVehicle

If you are using Vehicle Persistent and want to remove a parked vehicle, use the following export, which will allow you to remove the persistent vehicle.

```lua
--@param {vehicleId: number}: Vehicle ID
exports["vms_garagesv2"]:deleteVehicle(vehicleId)
```

***

### vehiclePersistence

Enables or disables persistence for a specific vehicle.\
If enabled, the vehicle will be saved and restored after a restart or resource reload.\
Use this export to dynamically toggle persistence for any spawned vehicle.

```lua
---@param {vehicleId: number}: Vehicle ID
---@param {toggle: boolean}: Enable or disable persistence
exports["vms_garagesv2"]:vehiclePersistence(vehicleId, toggle)
```

***

### updateParkedVehiclePlate

Export possible to an external resource for changing license plates. This export will be needed to update the current plates if the vehicle is currently parked.

```lua
---@param {lastPlate: string}: the current plate of the vehicle you want to change
---@param {newPlate: string}: new vehicle plate to be set up
---@param {updateSQL: boolean}: if you also want to update the properties and plate column with this export
exports["vms_garagesv2"]:updateParkedVehiclePlate(lastPlate, newPlate, updateSQL)
```

***

### isInInterior

Export to check if player is currently in any underground garage interiors.

```lua
---@param {source: number}: ID of the player
local garageName, outsideCoords = exports["vms_garagesv2"]:isInInterior(source)

---@return {garageName: string}: Id of the garage the player is currently in
---@return {outsideCoords: vector4}: Coordinates outside the interior
```

***

### getCompanyMoney

With this export, you can see how much money is in the parking safe.

```lua
-- @param {parkingId: string}: parkingId is the key of the garages table
local amount = exports["vms_garagesv2"]:getCompanyMoney(parkingId)
```

***

### addCompanyMoney

With this export you can add money to the parking safe.

```lua
---@param {parkingId: string}: parkingId is the key of the garages table
---@param {amount: number}: the amount to be added to the parking safe
---@param {addToTotalEarning: boolean}: Is the added money to be included in Total Earned
exports["vms_garagesv2"]:addCompanyMoney(parkingId, amount, addToTotalEarned)
```

***

### removeCompanyMoney

With this export you can remove money from the parking safe.

```lua
---@param {parkingId: string}: parkingId is the key of the garages table
---@param {amount: number}: the amount to be removed from the parking safe
exports["vms_garagesv2"]:removeCompanyMoney(parkingId, amount)
```

***

### getGarageInfo

Information about the garage such as the label and coordinates

```lua
---@param {garageId: string}: garageId is the key of the garages table
local label, coords = exports["vms_garagesv2"]:getGarageInfo(garageId)
```

***

### registerHousingGarage

Registers the garage assigned to a specific property in the housing system. The function automatically creates a garage file in the `CREATED_PARKINGS` folder, making the garage immediately available.

```lua
---@param {garageId: string | number}: The unique identifier of the garage - used as the file name and as the key in the `Config.HousingGarages` table, e.g., `"nolag_property-UNIQUE_ID"`.
---@param {label: string}: The label displayed to the player when interacting with the garage.
---@param {housingId: string | number}: The ID of the housing unit associated with the garage. It should match the ID used by the housing system.
---@param {coords: vector3}: The coordinates of the garage entry point - typically defined as part of the house's interaction point.
---@param {garageInterior: number | nil}: The ID of the garage interior, taken from `Config.ParkingCreator.HouseGarageInteriors`. Defaults to `1` if the specified ID is not found.
exports["vms_garagesv2"]:registerHousingGarage(
    garageId,
    label,
    housingId,
    coords,
    garageInterior
)
```

<details>

<summary>Example Usage</summary>

```lua
RegisterNetEvent('qb-houses:server:addGarage')
AddEventHandler('qb-houses:server:addGarage', function(name, coords)
    local name, coords = name, coords
    if name and coords and coords.x then
        CreateThread(function()
            exports["vms_garagesv2"]:registerHousingGarage(
                'qs-housing-' .. name,                            --[[ File name - Garage ID will always be as "HouseGarage:nolag_property-ID" ]]
                'Garage',                                         --[[ Garage Label ]]
                name,                                             --[[ Housing ID ]]
                vector4(coords.x, coords.y, coords.z, coords.h),  --[[ Coordinates ]]
                1                                                 --[[ Garage Interior ID (Config.ParkingCreator.HouseGarageInteriors) ]]
            )
        end)
    end
end)
```

</details>

***

### refreshVehicles

Refresh all vehicles based on the current database data in the specified parking lot.

```lua
---@param {garageId: string}: garageId is the key of the garages table
exports["vms_garagesv2"]:refreshVehicles(garageId)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vames-store.com/assets/vms_garagesv2/developer-api/server-exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
