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.
Trigger the following export when a vehicle is taken out from the garage, house, depot... basically when the vehicle is spawned to the player:
exports['av_cameras']:vehicleOut(vehicle)
This is an example for the export triggered from qb-garages:
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)
Last updated