diff --git a/resources/[carscripts]/jg-advancedgarages/config/config.lua b/resources/[carscripts]/jg-advancedgarages/config/config.lua index 6134a274a..67eeb1d0b 100644 --- a/resources/[carscripts]/jg-advancedgarages/config/config.lua +++ b/resources/[carscripts]/jg-advancedgarages/config/config.lua @@ -1,4 +1,4 @@ --- Generated with https://configurator.jgscripts.com at 8/7/2025, 10:59:08 AM +-- Generated with https://configurator.jgscripts.com at 8/7/2025, 11:44:33 AM Config = {} Config.Locale = 'de' @@ -34,8 +34,8 @@ Config.EnableTransfers = { betweenGarages = false, betweenPlayers = true, } -Config.AllowInfiniteVehicleSpawns = false -Config.JobGaragesAllowInfiniteVehicleSpawns = false +Config.AllowInfiniteVehicleSpawns = true +Config.JobGaragesAllowInfiniteVehicleSpawns = true Config.GangGaragesAllowInfiniteVehicleSpawns = false Config.GarageVehicleReturnCost = 0 Config.GarageVehicleReturnCostSocietyFund = false diff --git a/resources/[carscripts]/nordi_antidespawn/client/main.lua b/resources/[carscripts]/nordi_antidespawn/client/main.lua index 59d0d35ce..2f76c757a 100644 --- a/resources/[carscripts]/nordi_antidespawn/client/main.lua +++ b/resources/[carscripts]/nordi_antidespawn/client/main.lua @@ -382,6 +382,12 @@ CreateThread(function() if driver == playerPed and IsVehicleClassAllowed(currentVehicle) then local plate = QBCore.Functions.GetPlate(currentVehicle) + -- Skip vehicles with empty or invalid plates + if not plate or plate == "" or string.len(plate) < 2 then + Debug("Skipping vehicle with invalid plate") + goto continue + end + -- Anti-Duplication: Check if this plate already exists multiple times if DoesVehicleExistInWorld(plate) then Debug("Anti-Dupe: Detected duplicate vehicle with plate " .. plate .. ", not tracking") @@ -390,26 +396,34 @@ CreateThread(function() -- Check if this vehicle is already being tracked if not trackedVehicles[plate] and not garagePending[plate] then - -- Track all vehicles, regardless of ownership - trackedVehicles[plate] = currentVehicle - - -- Speichere letzte bekannte Position - lastKnownCoords[plate] = GetEntityCoords(currentVehicle) - - -- Sofort starke Despawn-Verhinderung - PreventDespawn(currentVehicle) - - Debug("Fahrzeug wird nun getrackt: " .. plate) - - -- Hole Fahrzeugmods - local vehicleMods = GetVehicleMods(currentVehicle) - - -- Registriere Fahrzeug beim Server - local vehicleCoords = GetEntityCoords(currentVehicle) - local vehicleHeading = GetEntityHeading(currentVehicle) - local vehicleModel = GetEntityModel(currentVehicle) - - TriggerServerEvent('antidespawn:server:registerVehicle', plate, vehicleModel, vehicleCoords, vehicleHeading, vehicleMods) + -- First verify this vehicle exists in the database + TriggerServerEvent('antidespawn:server:checkVehicleExists', plate, function(exists) + if not exists then + Debug("Vehicle not in database, not tracking: " .. plate) + return + end + + -- Track all vehicles that exist in the database + trackedVehicles[plate] = currentVehicle + + -- Speichere letzte bekannte Position + lastKnownCoords[plate] = GetEntityCoords(currentVehicle) + + -- Sofort starke Despawn-Verhinderung + PreventDespawn(currentVehicle) + + Debug("Fahrzeug wird nun getrackt: " .. plate) + + -- Hole Fahrzeugmods + local vehicleMods = GetVehicleMods(currentVehicle) + + -- Registriere Fahrzeug beim Server + local vehicleCoords = GetEntityCoords(currentVehicle) + local vehicleHeading = GetEntityHeading(currentVehicle) + local vehicleModel = GetEntityModel(currentVehicle) + + TriggerServerEvent('antidespawn:server:registerVehicle', plate, vehicleModel, vehicleCoords, vehicleHeading, vehicleMods) + end) end end end