diff --git a/resources/[jobs]/[civ]/mh_jobgarage/client/chiefsettings.lua b/resources/[jobs]/[civ]/mh_jobgarage/client/chiefsettings.lua index b3607b664..3c3f42b69 100644 --- a/resources/[jobs]/[civ]/mh_jobgarage/client/chiefsettings.lua +++ b/resources/[jobs]/[civ]/mh_jobgarage/client/chiefsettings.lua @@ -36,38 +36,28 @@ function OpenChiefMenu(vehicles) lib.showContext("ChiefSettingsMenu") end - -function IsVehicleSpawned(plate) - - local vehicles = GetGamePool('CVehicle') - - for _, vehicle in ipairs(vehicles) do - if DoesEntityExist(vehicle) then - local mods = QBCore.Functions.GetVehicleProperties(vehicle) - local vehiclePlate = mods.plate - - if vehiclePlate == plate then - print("Function: "..mods) - return true, mods - end - end - end - - return false, nil -- Vehicle not found -end - function OpenChiefAddVehicleMenu() local Player = QBCore.Functions.GetPlayerData() local opt = {} QBCore.Functions.TriggerCallback('mh_jobgarage:CallOwnerVehicles', function(vehicles) - Wait(300) - print(json.encode(vehicles)) + Wait(300) + print(json.encode(vehicles)) if vehicles ~= false then local opt = {} for i = 1, #vehicles, 1 do - local isSpawned, mods = IsVehicleSpawned(vehicles[i].plate) + local isSpawned = false + local mods = {} + + local allVehicles = GetGamePool('CVehicle') + + for _, v in ipairs(allVehicles) do + if DoesEntityExist(v) then + isSpawned = true + mods = QBCore.Functions.GetVehicleProperties(v) + end + end if isSpawned then print("Chiefsettings: "..mods)