forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
1d404bab45
commit
d1471da813
1 changed files with 45 additions and 50 deletions
|
@ -127,76 +127,71 @@ function GetTaxiSpawnPosition(playerCoords)
|
||||||
if foundGround then
|
if foundGround then
|
||||||
local spawnCoords = vector4(x, y, z, math.deg(angle))
|
local spawnCoords = vector4(x, y, z, math.deg(angle))
|
||||||
|
|
||||||
-- Prüfen ob Position frei ist
|
-- Prüfen ob Position frei ist (ohne IsPositionClear)
|
||||||
if IsPositionClear(spawnCoords.x, spawnCoords.y, spawnCoords.z, 3.0, true, false, false, false, false) then
|
local clearArea = true
|
||||||
|
local vehicles = GetGamePool('CVehicle')
|
||||||
|
|
||||||
|
-- Prüfen ob andere Fahrzeuge in der Nähe sind
|
||||||
|
for _, vehicle in ipairs(vehicles) do
|
||||||
|
local vehCoords = GetEntityCoords(vehicle)
|
||||||
|
if #(vector3(x, y, z) - vehCoords) < 5.0 then
|
||||||
|
clearArea = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Prüfen ob Peds in der Nähe sind
|
||||||
|
if clearArea then
|
||||||
|
local peds = GetGamePool('CPed')
|
||||||
|
for _, ped in ipairs(peds) do
|
||||||
|
local pedCoords = GetEntityCoords(ped)
|
||||||
|
if #(vector3(x, y, z) - pedCoords) < 5.0 then
|
||||||
|
clearArea = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Prüfen ob Position auf einer Straße ist
|
||||||
|
if clearArea then
|
||||||
|
local isOnRoad = IsPointOnRoad(x, y, z, 0)
|
||||||
|
if isOnRoad then
|
||||||
print("^2[TAXI DEBUG]^7 Found spawn position at attempt " .. i)
|
print("^2[TAXI DEBUG]^7 Found spawn position at attempt " .. i)
|
||||||
return spawnCoords
|
return spawnCoords
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
spawnDistance = spawnDistance + 20.0
|
spawnDistance = spawnDistance + 20.0
|
||||||
end
|
end
|
||||||
|
|
||||||
print("^1[TAXI DEBUG]^7 No spawn position found after " .. maxAttempts .. " attempts")
|
print("^1[TAXI DEBUG]^7 No spawn position found after " .. maxAttempts .. " attempts")
|
||||||
|
|
||||||
|
-- Fallback: Verwende eine der vordefinierten Spawn-Positionen
|
||||||
|
if Config.MobileTaxiSpawns and #Config.MobileTaxiSpawns > 0 then
|
||||||
|
local randomSpawn = Config.MobileTaxiSpawns[math.random(#Config.MobileTaxiSpawns)]
|
||||||
|
print("^3[TAXI DEBUG]^7 Using fallback spawn position")
|
||||||
|
return randomSpawn
|
||||||
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function SpawnTaxi(coords)
|
|
||||||
print("^2[TAXI DEBUG]^7 Spawning taxi at: " .. tostring(coords))
|
|
||||||
|
|
||||||
local taxiModel = GetHashKey(Config.TaxiModel)
|
|
||||||
print("^2[TAXI DEBUG]^7 Taxi model hash: " .. taxiModel)
|
|
||||||
|
|
||||||
RequestModel(taxiModel)
|
|
||||||
local timeout = GetGameTimer() + 10000
|
|
||||||
while not HasModelLoaded(taxiModel) and GetGameTimer() < timeout do
|
|
||||||
print("^3[TAXI DEBUG]^7 Waiting for taxi model to load...")
|
|
||||||
Wait(100)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not HasModelLoaded(taxiModel) then
|
|
||||||
print("^1[TAXI DEBUG]^7 Failed to load taxi model!")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local taxi = CreateVehicle(taxiModel, coords.x, coords.y, coords.z, coords.w, true, false)
|
|
||||||
|
|
||||||
if not DoesEntityExist(taxi) then
|
|
||||||
print("^1[TAXI DEBUG]^7 Failed to create taxi vehicle!")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
print("^2[TAXI DEBUG]^7 Taxi created successfully: " .. taxi)
|
|
||||||
|
|
||||||
SetEntityAsMissionEntity(taxi, true, true)
|
|
||||||
SetVehicleOnGroundProperly(taxi)
|
|
||||||
SetVehicleEngineOn(taxi, true, true, false)
|
|
||||||
SetVehicleDoorsLocked(taxi, 2) -- Locked initially
|
|
||||||
|
|
||||||
-- Taxi-Livery setzen falls verfügbar
|
|
||||||
local liveryCount = GetVehicleLiveryCount(taxi)
|
|
||||||
if liveryCount > 0 then
|
|
||||||
SetVehicleLivery(taxi, 0) -- Erste Livery verwenden
|
|
||||||
print("^2[TAXI DEBUG]^7 Taxi livery set")
|
|
||||||
end
|
|
||||||
|
|
||||||
SetModelAsNoLongerNeeded(taxiModel)
|
|
||||||
return taxi
|
|
||||||
end
|
|
||||||
|
|
||||||
function SpawnTaxiDriver(vehicle)
|
function SpawnTaxiDriver(vehicle)
|
||||||
print("^2[TAXI DEBUG]^7 Spawning taxi driver...")
|
print("^2[TAXI DEBUG]^7 Spawning taxi driver...")
|
||||||
|
|
||||||
-- Bessere Fahrer-Models mit Fallbacks
|
-- Bessere Fahrer-Models mit Fallbacks
|
||||||
local driverModels = {
|
local driverModels = {
|
||||||
"mp_m_freemode_01", -- Standard Male (sollte immer verfügbar sein)
|
"A_C_Chimp", -- Standard Male (sollte immer verfügbar sein)
|
||||||
"mp_f_freemode_01", -- Standard Female
|
"G_M_M_ArmGoon_01", -- Standard Female
|
||||||
"a_m_y_business_01", -- Business Male
|
"a_m_y_business_01", -- Business Male
|
||||||
"a_f_y_business_01", -- Business Female
|
"a_f_y_business_01", -- Business Female
|
||||||
"a_m_m_business_01", -- Business Male 2
|
"a_m_m_business_01", -- Business Male 2
|
||||||
"a_m_y_downtown_01", -- Downtown Male
|
"a_m_y_downtown_01", -- Downtown Male
|
||||||
"s_m_m_pilot_01", -- Pilot
|
"A_M_O_GenStreet_01", -- Pilot
|
||||||
"s_m_y_dealer_01" -- Dealer
|
"CS_Manuel" -- Dealer
|
||||||
|
"U_M_M_Jesus_01" -- Jesus
|
||||||
}
|
}
|
||||||
|
|
||||||
local driver = nil
|
local driver = nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue