Only Restore Damaged When Vehicle Value is Reduced

This commit is contained in:
2025-03-06 19:14:55 +01:00
parent 5929cdff5f
commit 17d90c2699
2 changed files with 11 additions and 6 deletions

View File

@@ -16,7 +16,7 @@
local M = {}
M.dependencies = { 'career_modules_inventory', 'freeroam_facilities', "career_vehicleSaveSystem",
"career_modules_permissions" }
"career_modules_permissions", 'career_modules_valueCalculator' }
local career_modules_inventory_removeVehicleObject
local vehicleObjectsToRemove = {}
@@ -34,6 +34,10 @@ local function Retrieve(inventoryId)
if not career_vehicleSaveSystem.SaveVehicle(inventoryId) then
career_vehicleSaveSystem.QueuedVehicleSaved(inventoryId)
end
local vehicleValue = career_modules_valueCalculator.getInventoryVehicleValue(inventoryId, true)
local currentVehicleValue = career_modules_valueCalculator.getInventoryVehicleValue(inventoryId)
career_vehicleSaveSystem.CheckSavedAsync(function()
extensions.core_jobsystem.create(
function(job)
@@ -42,7 +46,11 @@ local function Retrieve(inventoryId)
local location = { pos = veh:getPosition(), rot = quat(0, 0, 1, 0) * quat(veh:getRefNodeRotation()) }
local garage = career_modules_inventory.getClosestGarage(location.pos)
job.sleep(1)
career_vehicleSaveSystem.LoadVehicle(inventoryId)
if currentVehicleValue < vehicleValue then
career_vehicleSaveSystem.LoadVehicle(inventoryId)
else
log('I', 'retrieval', 'retrieving vehicle ' .. inventoryId .. " in an undamaged state")
end
freeroam_facilities.teleportToGarage(garage.id, veh, false)
end)
end