Does anyone know how I would be able to return a table of vehicles in a radius?
My aim is to create a command to repair all vehicles in a given radius
Something like this:
RegisterCommand('repairv', function(source,args)
local carsTable = {}
// Get the vehicles in radius args[1] and return in carsTable
TriggerClientEvent('repairvehicles', source, carsTable)
end)
Example which you can use an example, simply change the checking if the seat is empty, to check if its damaged then repair it.
local vehiclePool = GetGamePool('CVehicle') -- Get the list of vehicles (entities) from the pool
for i = 1, #vehiclePool do -- loop through each vehicle (entity)
if GetPedInVehicleSeat(vehiclePool[i], -1) == 0 then
DeleteEntity(vehiclePool[i]) -- Delete vehicles (entities) that don't have a driver
end
end```