diff --git a/[core]/mercyv-garage/client/main.lua b/[core]/mercyv-garage/client/main.lua index 57f6b1af..0f893934 100644 --- a/[core]/mercyv-garage/client/main.lua +++ b/[core]/mercyv-garage/client/main.lua @@ -499,7 +499,11 @@ end) function SpawnVehicle(data, closeGarageAfter) local g = Garages[data.garageId] - if not g then return end + if not g then + print('[mercyv-garage] SpawnVehicle: Garage nicht gefunden: ' .. tostring(data.garageId)) + if closeGarageAfter then CloseGarage() end + return + end local gType = g.garage or 'normal' local spawn @@ -516,9 +520,27 @@ function SpawnVehicle(data, closeGarageAfter) z = pedCoords.z, w = heading, } - else + elseif g.car and g.car.spawncar then spawn = g.car.spawncar + else + -- Fallback: 5m vor Spieler spawnen + local pedCoords = GetEntityCoords(PlayerPedId()) + local heading = GetEntityHeading(PlayerPedId()) + local rad = math.rad(heading) + spawn = { + x = pedCoords.x + math.sin(-rad) * 5.0, + y = pedCoords.y + math.cos(-rad) * 5.0, + z = pedCoords.z, + w = heading, + } end + + if not spawn then + print('[mercyv-garage] ERROR: Keine Spawn-Koordinaten für ' .. tostring(data.garageId)) + if closeGarageAfter then CloseGarage() end + return + end + local props = type(data.props) == 'string' and json.decode(data.props) or data.props local model = nil