forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
07aee0f73e
commit
88ffeb3375
1 changed files with 20 additions and 12 deletions
|
@ -571,35 +571,44 @@ CreateThread(function()
|
||||||
goto continue
|
goto continue
|
||||||
end
|
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
|
-- Verify this vehicle still exists in the database before respawning
|
||||||
CheckVehicleExists(plate, function(exists)
|
CheckVehicleExists(plate, function(exists)
|
||||||
if not exists then
|
if not exists then
|
||||||
Debug("Vehicle no longer in database, not respawning: " .. plate)
|
Debug("Vehicle no longer in database, not respawning: " .. currentPlate)
|
||||||
trackedVehicles[plate] = nil
|
trackedVehicles[currentPlate] = nil
|
||||||
lastKnownCoords[plate] = nil
|
lastKnownCoords[currentPlate] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Versuche Fahrzeug wiederherzustellen, aber nur wenn es nicht in die Garage gestellt wird
|
-- Versuche Fahrzeug wiederherzustellen, aber nur wenn es nicht in die Garage gestellt wird
|
||||||
if lastKnownCoords[plate] and not garagePending[plate] then
|
if currentCoords and not garagePending[currentPlate] then
|
||||||
Debug("Versuche Fahrzeug wiederherzustellen: " .. plate)
|
Debug("Versuche Fahrzeug wiederherzustellen: " .. currentPlate)
|
||||||
TriggerServerEvent('antidespawn:server:respawnVehicle', plate)
|
TriggerServerEvent('antidespawn:server:respawnVehicle', currentPlate)
|
||||||
|
|
||||||
-- Entferne aus lokaler Tracking-Liste, wird nach Respawn wieder hinzugefügt
|
-- Entferne aus lokaler Tracking-Liste, wird nach Respawn wieder hinzugefügt
|
||||||
trackedVehicles[plate] = nil
|
trackedVehicles[currentPlate] = nil
|
||||||
lastKnownCoords[plate] = nil
|
lastKnownCoords[currentPlate] = nil
|
||||||
else
|
else
|
||||||
-- Entferne aus Tracking
|
-- Entferne aus Tracking
|
||||||
trackedVehicles[plate] = nil
|
trackedVehicles[currentPlate] = nil
|
||||||
lastKnownCoords[plate] = nil
|
lastKnownCoords[currentPlate] = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Remove from tracking immediately to avoid processing it again while waiting for the callback
|
||||||
|
trackedVehicles[plate] = nil
|
||||||
|
lastKnownCoords[plate] = nil
|
||||||
end
|
end
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Lade Fahrzeuge beim Spawn
|
-- Lade Fahrzeuge beim Spawn
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||||
Debug("Spieler geladen, warte vor dem Laden der Fahrzeuge...")
|
Debug("Spieler geladen, warte vor dem Laden der Fahrzeuge...")
|
||||||
|
@ -760,14 +769,13 @@ RegisterNetEvent('antidespawn:client:spawnVehicle', function(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
SetModelAsNoLongerNeeded(modelHash)
|
SetModelAsNoLongerNeeded(modelHash)
|
||||||
else
|
|
||||||
Debug("Modell konnte nicht geladen werden: " ..
|
|
||||||
else
|
else
|
||||||
Debug("Modell konnte nicht geladen werden: " .. data.plate .. " (Hash: " .. tostring(modelHash) .. ")")
|
Debug("Modell konnte nicht geladen werden: " .. data.plate .. " (Hash: " .. tostring(modelHash) .. ")")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Event für Garage Store (wird ausgelöst, wenn der Spieler ein Fahrzeug in die Garage stellen will)
|
-- 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)
|
RegisterNetEvent('jg-advancedgarages:client:store-vehicle', function(garageId, garageVehicleType)
|
||||||
local playerPed = PlayerPedId()
|
local playerPed = PlayerPedId()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue