forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
4b341b6b96
commit
7981aba9e5
1 changed files with 87 additions and 0 deletions
|
@ -293,6 +293,12 @@ function SpawnTaxi(coords)
|
|||
|
||||
-- Fahrzeug konfigurieren
|
||||
SetEntityAsMissionEntity(taxi, true, true)
|
||||
SetEntityInvincible(taxi, true)
|
||||
SetVehicleCanBeVisiblyDamaged(taxi, false)
|
||||
SetEntityProofs(taxi, true, true, true, true, true, true, true, true)
|
||||
SetVehicleExplodesOnHighExplosionDamage(taxi, false)
|
||||
SetVehicleHasBeenOwnedByPlayer(taxi, true)
|
||||
SetVehicleIsConsideredByPlayer(taxi, true)
|
||||
SetVehicleOnGroundProperly(taxi)
|
||||
SetVehicleEngineOn(taxi, true, true, false)
|
||||
SetVehicleDoorsLocked(taxi, 2) -- Locked initially
|
||||
|
@ -1277,3 +1283,84 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
print("^2[TAXI DEBUG]^7 Main cleanup completed")
|
||||
end
|
||||
end)
|
||||
|
||||
-- Starte die Taxi-Überwachung
|
||||
function MonitorTaxiExistence()
|
||||
CreateThread(function()
|
||||
local lastKnownPosition = nil
|
||||
local lastKnownHeading = 0.0
|
||||
|
||||
while true do
|
||||
Wait(2000) -- Alle 2 Sekunden prüfen
|
||||
|
||||
if currentTaxi ~= nil then
|
||||
if DoesEntityExist(currentTaxi) then
|
||||
-- Speichere aktuelle Position für Notfall-Respawn
|
||||
lastKnownPosition = GetEntityCoords(currentTaxi)
|
||||
lastKnownHeading = GetEntityHeading(currentTaxi)
|
||||
else
|
||||
-- Taxi existiert nicht mehr, aber sollte existieren
|
||||
print("^1[TAXI DEBUG]^7 Taxi disappeared unexpectedly, respawning...")
|
||||
|
||||
-- Speichere wichtige Informationen
|
||||
local hadDriver = (currentDriver ~= nil and DoesEntityExist(currentDriver))
|
||||
local playerInTaxi = false
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
-- Altes Taxi und Fahrer aufräumen
|
||||
if currentDriver and DoesEntityExist(currentDriver) then
|
||||
DeleteEntity(currentDriver)
|
||||
end
|
||||
currentDriver = nil
|
||||
|
||||
-- Bestimme Respawn-Position
|
||||
local respawnPos
|
||||
if lastKnownPosition then
|
||||
respawnPos = {
|
||||
x = lastKnownPosition.x,
|
||||
y = lastKnownPosition.y,
|
||||
z = lastKnownPosition.z,
|
||||
w = lastKnownHeading
|
||||
}
|
||||
else
|
||||
-- Fallback: In der Nähe des Spielers spawnen
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
respawnPos = {
|
||||
x = playerCoords.x + math.random(-10, 10),
|
||||
y = playerCoords.y + math.random(-10, 10),
|
||||
z = playerCoords.z,
|
||||
w = 0.0
|
||||
}
|
||||
end
|
||||
|
||||
-- Neues Taxi spawnen
|
||||
local newTaxi = SpawnTaxi(respawnPos)
|
||||
if newTaxi then
|
||||
currentTaxi = newTaxi
|
||||
|
||||
-- Neuen Fahrer spawnen wenn nötig
|
||||
if hadDriver then
|
||||
local newDriver = SpawnTaxiDriver(newTaxi)
|
||||
if newDriver then
|
||||
currentDriver = newDriver
|
||||
|
||||
-- Navigation fortsetzen wenn nötig
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
NavigateToPlayer(currentDriver, currentTaxi, playerCoords)
|
||||
end
|
||||
end
|
||||
|
||||
-- Blips neu erstellen
|
||||
CreateTaxiBlips(newTaxi)
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Dein Taxi wurde ersetzt.',
|
||||
type = 'info'
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue