From 79a5801e6284da2593e3ac9ab3fe73a004fd9ac9 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Mon, 28 Jul 2025 05:21:23 +0200 Subject: [PATCH] Update main.lua --- .../[carscripts]/nordi_seats/client/main.lua | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/resources/[carscripts]/nordi_seats/client/main.lua b/resources/[carscripts]/nordi_seats/client/main.lua index 3bf15ce27..a0bcb3351 100644 --- a/resources/[carscripts]/nordi_seats/client/main.lua +++ b/resources/[carscripts]/nordi_seats/client/main.lua @@ -22,6 +22,28 @@ local seatNames = { [9] = "Deck 6" } +-- Funktion um aktuellen Sitz zu bekommen +local function getCurrentSeat(ped, vehicle) + if not IsPedInVehicle(ped, vehicle, false) then + return nil + end + + -- Prüfe Fahrersitz + if GetPedInVehicleSeat(vehicle, -1) == ped then + return -1 + end + + -- Prüfe Passagiersitze + local maxSeats = GetVehicleMaxNumberOfPassengers(vehicle) + for i = 0, maxSeats - 1 do + if GetPedInVehicleSeat(vehicle, i) == ped then + return i + end + end + + return nil +end + -- Prüfe ob Fahrzeug ein Boot ist local function isBoat(vehicle) local vehicleClass = GetVehicleClass(vehicle) @@ -78,6 +100,7 @@ local function toggleAnchor(vehicle) -- Kleine Wellen-Animation for i = 1, 5 do + local coords = GetEntityCoords(vehicle) local waterHeight = GetWaterHeight(coords.x, coords.y, coords.z) if waterHeight then -- Erstelle Wasser-Effekt um das Boot @@ -90,7 +113,7 @@ local function toggleAnchor(vehicle) for j = 1, 3 do local offsetX = math.random(-200, 200) / 100 local offsetY = math.random(-200, 200) / 100 - UsePartikelFxAssetNextCall(effect) + UseParticleFxAssetNextCall(effect) StartParticleFxNonLoopedAtCoord("ent_sht_water", coords.x + offsetX, coords.y + offsetY, waterHeight, 0.0, 0.0, 0.0, 0.5, false, false, false) end end @@ -313,7 +336,7 @@ local function showSeatMenu(vehicle) -- Anker-Kontrolle (nur für Boote und nur wenn im Boot) if isVehicleBoat and isInVehicle then - local currentSeat = GetPedVehicleSeat(playerPed) + local currentSeat = getCurrentSeat(playerPed, vehicle) -- Nur Kapitän kann Anker bedienen if currentSeat == -1 then table.insert(options, { @@ -571,8 +594,8 @@ RegisterCommand('anchor', function() local vehicle = GetVehiclePedIsIn(playerPed, false) if vehicle ~= 0 and isBoat(vehicle) then - local seat = GetPedVehicleSeat(playerPed) - if seat == -1 then -- Nur Kapitän + local currentSeat = getCurrentSeat(playerPed, vehicle) + if currentSeat == -1 then -- Nur Kapitän toggleAnchor(vehicle) else QBCore.Functions.Notify('Nur der Kapitän kann den Anker bedienen!', 'error')