# Vehicle Cameras

> In order to make vehicle cameras detect when a vehicle is available, you need to add the following exports to your garage script, otherwise the camera APP won't be able to fetch online vehicles.

{% tabs %}
{% tab title="Vehicle Out" %}

> Trigger the following export when a vehicle is taken out from the garage, house, depot... basically when the vehicle is spawned to the player:

```lua
exports['av_cameras']:vehicleOut(vehicle)
```

> This is an example for the export triggered from **qb-garages**:

{% code title="qb-garages/client/main.lua" %}

```lua
RegisterNetEvent('qb-garages:client:takeOutGarage', function(data)
    QBCore.Functions.TriggerCallback('qb-garages:server:IsSpawnOk', function(spawn)
        if spawn then
            local location = GetSpawnPoint(data.garage)
            if not location then return end
            QBCore.Functions.TriggerCallback('qb-garages:server:spawnvehicle', function(netId, properties, vehPlate)
                while not NetworkDoesNetworkIdExist(netId) do Wait(10) end
                local veh = NetworkGetEntityFromNetworkId(netId)
                Citizen.Await(CheckPlate(veh, vehPlate))
                QBCore.Functions.SetVehicleProperties(veh, properties)
                TriggerServerEvent('qb-garages:server:updateVehicleState', 0, vehPlate)
                TriggerEvent('vehiclekeys:client:SetOwner', vehPlate)
                if Config.Warp then TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1) end
                if Config.VisuallyDamageCars then doCarDamage(veh, data.stats, properties) end
                SetVehicleEngineOn(veh, true, true, false)
                exports['av_cameras']:vehicleOut(veh) -- Trigger the export and send the entity
            end, data.plate, data.vehicle, location, true)
        else
            QBCore.Functions.Notify(Lang:t('error.not_depot'), 'error', 5000)
        end
    end, data.plate, data.type)
end)
```

{% endcode %}
{% endtab %}

{% tab title="Vehicle Stored" %}

> It removes the vehicle from the server cameras and makes it unavailable for the user, trigger it when the vehicle is stored in a garage/house/depot or just got deleted by any script.

```lua
exports['av_cameras']:vehicleIn(vehicle)
```

> Make sure to trigger the export when the vehicle still exists and NOT after getting deleted, this example is for qb-garages:

```lua
local function DepositVehicle(veh, data)
    local plate = QBCore.Functions.GetPlate(veh)
    QBCore.Functions.TriggerCallback('qb-garages:server:canDeposit', function(canDeposit)
        if canDeposit then
            exports['av_cameras']:vehicleIn(veh)
            local bodyDamage = math.ceil(GetVehicleBodyHealth(veh))
            local engineDamage = math.ceil(GetVehicleEngineHealth(veh))
            local totalFuel = 1000.0
            TriggerServerEvent('qb-mechanicjob:server:SaveVehicleProps', QBCore.Functions.GetVehicleProperties(veh))
            TriggerServerEvent('qb-garages:server:updateVehicleStats', plate, totalFuel, engineDamage, bodyDamage)
            CheckPlayers(veh)
            if plate then TriggerServerEvent('qb-garages:server:UpdateOutsideVehicle', plate, nil) end
            QBCore.Functions.Notify(Lang:t('success.vehicle_parked'), 'primary', 4500)
        else
            QBCore.Functions.Notify(Lang:t('error.not_owned'), 'error', 3500)
        end
    end, plate, data.type, data.indexgarage, 1)
end
```

{% endtab %}
{% endtabs %}
