1
0
Fork 0
forked from Simnation/Main

Update main.lua

This commit is contained in:
Nordi98 2025-08-07 14:12:28 +02:00
parent 07aee0f73e
commit 88ffeb3375

View file

@ -571,35 +571,44 @@ CreateThread(function()
goto continue
end
-- Store the plate and coords for use in the callback
local currentPlate = plate
local currentCoords = lastKnownCoords[plate]
-- Verify this vehicle still exists in the database before respawning
CheckVehicleExists(plate, function(exists)
if not exists then
Debug("Vehicle no longer in database, not respawning: " .. plate)
trackedVehicles[plate] = nil
lastKnownCoords[plate] = nil
Debug("Vehicle no longer in database, not respawning: " .. currentPlate)
trackedVehicles[currentPlate] = nil
lastKnownCoords[currentPlate] = nil
return
end
-- Versuche Fahrzeug wiederherzustellen, aber nur wenn es nicht in die Garage gestellt wird
if lastKnownCoords[plate] and not garagePending[plate] then
Debug("Versuche Fahrzeug wiederherzustellen: " .. plate)
TriggerServerEvent('antidespawn:server:respawnVehicle', plate)
if currentCoords and not garagePending[currentPlate] then
Debug("Versuche Fahrzeug wiederherzustellen: " .. currentPlate)
TriggerServerEvent('antidespawn:server:respawnVehicle', currentPlate)
-- Entferne aus lokaler Tracking-Liste, wird nach Respawn wieder hinzugefügt
trackedVehicles[plate] = nil
lastKnownCoords[plate] = nil
trackedVehicles[currentPlate] = nil
lastKnownCoords[currentPlate] = nil
else
-- Entferne aus Tracking
trackedVehicles[plate] = nil
lastKnownCoords[plate] = nil
trackedVehicles[currentPlate] = nil
lastKnownCoords[currentPlate] = nil
end
end)
-- Remove from tracking immediately to avoid processing it again while waiting for the callback
trackedVehicles[plate] = nil
lastKnownCoords[plate] = nil
end
::continue::
end
end
end)
-- Lade Fahrzeuge beim Spawn
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Debug("Spieler geladen, warte vor dem Laden der Fahrzeuge...")
@ -760,14 +769,13 @@ RegisterNetEvent('antidespawn:client:spawnVehicle', function(data)
end
SetModelAsNoLongerNeeded(modelHash)
else
Debug("Modell konnte nicht geladen werden: " ..
else
Debug("Modell konnte nicht geladen werden: " .. data.plate .. " (Hash: " .. tostring(modelHash) .. ")")
end
end)
end)
-- Event für Garage Store (wird ausgelöst, wenn der Spieler ein Fahrzeug in die Garage stellen will)
RegisterNetEvent('jg-advancedgarages:client:store-vehicle', function(garageId, garageVehicleType)
local playerPed = PlayerPedId()