From 0b8ab3c19ab4d816e346e504f2e18cf80f50b8a4 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Mon, 28 Jul 2025 03:55:09 +0200 Subject: [PATCH] Update main.lua --- .../[carscripts]/nordi_seats/client/main.lua | 169 +++++++++++++----- 1 file changed, 122 insertions(+), 47 deletions(-) diff --git a/resources/[carscripts]/nordi_seats/client/main.lua b/resources/[carscripts]/nordi_seats/client/main.lua index 9d43be7cf..27d5b82f8 100644 --- a/resources/[carscripts]/nordi_seats/client/main.lua +++ b/resources/[carscripts]/nordi_seats/client/main.lua @@ -1,21 +1,34 @@ local QBCore = exports['qb-core']:GetCoreObject() local currentVehicle = nil +-- Boot-Klassen für spezielle Behandlung +local boatClasses = { + [14] = true, -- Boats + [15] = true, -- Helicopters (falls gewünscht) + [16] = true -- Planes (falls gewünscht) +} + -- Sitz-Namen für bessere Anzeige local seatNames = { - [-1] = "Fahrer", + [-1] = "Kapitän", [0] = "Beifahrer", [1] = "Hinten Links", [2] = "Hinten Rechts", [3] = "Hinten Mitte", - [4] = "Extra 1", - [5] = "Extra 2", - [6] = "Extra 3", - [7] = "Extra 4", - [8] = "Extra 5", - [9] = "Extra 6" + [4] = "Deck 1", + [5] = "Deck 2", + [6] = "Deck 3", + [7] = "Deck 4", + [8] = "Deck 5", + [9] = "Deck 6" } +-- Prüfe ob Fahrzeug ein Boot ist +local function isBoat(vehicle) + local vehicleClass = GetVehicleClass(vehicle) + return boatClasses[vehicleClass] or false +end + -- Funktion um verfügbare Sitze zu bekommen local function getAvailableSeats(vehicle) local seats = {} @@ -23,10 +36,11 @@ local function getAvailableSeats(vehicle) -- Fahrersitz (-1) if IsVehicleSeatFree(vehicle, -1) then + local seatName = isBoat(vehicle) and seatNames[-1] or "Fahrer" table.insert(seats, { index = -1, - name = seatNames[-1], - icon = "fas fa-steering-wheel" + name = seatName, + icon = isBoat(vehicle) and "fas fa-anchor" or "fas fa-steering-wheel" }) end @@ -63,11 +77,12 @@ local function getOccupiedSeats(vehicle) playerName = "NPC" end + local seatName = isBoat(vehicle) and seatNames[-1] or "Fahrer" table.insert(occupiedSeats, { index = -1, - name = seatNames[-1], + name = seatName, occupant = playerName, - icon = "fas fa-steering-wheel" + icon = isBoat(vehicle) and "fas fa-anchor" or "fas fa-steering-wheel" }) end @@ -98,7 +113,39 @@ local function getOccupiedSeats(vehicle) return occupiedSeats end --- Funktion zum Einsteigen +-- Funktion zum direkten Einsteigen (für Boote) +local function teleportToSeat(vehicle, seatIndex) + local playerPed = PlayerPedId() + + if IsPedInAnyVehicle(playerPed, false) then + QBCore.Functions.Notify('Du bist bereits in einem Fahrzeug!', 'error') + return + end + + if not IsVehicleSeatFree(vehicle, seatIndex) then + QBCore.Functions.Notify('Dieser Sitz ist bereits belegt!', 'error') + return + end + + -- Prüfe ob Fahrzeug abgeschlossen ist + if GetVehicleDoorLockStatus(vehicle) == 2 then + QBCore.Functions.Notify('Das Fahrzeug ist abgeschlossen!', 'error') + return + end + + -- Direkte Teleportation ohne Animation + SetPedIntoVehicle(playerPed, vehicle, seatIndex) + currentVehicle = vehicle + + local seatName = seatNames[seatIndex] or "Sitz " .. (seatIndex + 1) + if isBoat(vehicle) then + QBCore.Functions.Notify('Willkommen an Bord! (' .. seatName .. ')', 'success') + else + QBCore.Functions.Notify('Du bist eingestiegen (' .. seatName .. ')', 'success') + end +end + +-- Funktion zum normalen Einsteigen (für Autos) local function enterVehicleSeat(vehicle, seatIndex) local playerPed = PlayerPedId() @@ -139,11 +186,15 @@ local function switchSeat(vehicle, newSeatIndex) return end - TaskShuffleToNextVehicleSeat(playerPed, vehicle) - Wait(100) - - -- Setze auf gewünschten Sitz - SetPedIntoVehicle(playerPed, vehicle, newSeatIndex) + -- Für Boote: Direkte Teleportation + if isBoat(vehicle) then + SetPedIntoVehicle(playerPed, vehicle, newSeatIndex) + else + -- Für Autos: Normale Animation + TaskShuffleToNextVehicleSeat(playerPed, vehicle) + Wait(100) + SetPedIntoVehicle(playerPed, vehicle, newSeatIndex) + end local seatName = seatNames[newSeatIndex] or "Sitz " .. (newSeatIndex + 1) QBCore.Functions.Notify('Gewechselt zu: ' .. seatName, 'success') @@ -155,6 +206,7 @@ local function showSeatMenu(vehicle) local isInVehicle = IsPedInVehicle(playerPed, vehicle, false) local availableSeats = getAvailableSeats(vehicle) local occupiedSeats = getOccupiedSeats(vehicle) + local isVehicleBoat = isBoat(vehicle) local options = {} -- Header @@ -164,24 +216,37 @@ local function showSeatMenu(vehicle) vehicleLabel = vehicleName end + -- Boot-spezifische Anzeige + if isVehicleBoat then + vehicleLabel = "⛵ " .. vehicleLabel + else + vehicleLabel = "🚗 " .. vehicleLabel + end + -- Verfügbare Sitze if #availableSeats > 0 then + local headerText = isVehicleBoat and '🟢 Verfügbare Plätze' or '🟢 Verfügbare Sitze' table.insert(options, { - title = '🟢 Verfügbare Sitze', - description = 'Freie Sitzplätze', + title = headerText, + description = isVehicleBoat and 'Freie Plätze an Bord' or 'Freie Sitzplätze', disabled = true }) for _, seat in pairs(availableSeats) do + local actionText = isInVehicle and 'Zu diesem Platz wechseln' or (isVehicleBoat and 'An Bord gehen' or 'In das Fahrzeug einsteigen') table.insert(options, { title = seat.name, - description = isInVehicle and 'Zu diesem Sitz wechseln' or 'In das Fahrzeug einsteigen', + description = actionText, icon = seat.icon, onSelect = function() if isInVehicle then switchSeat(vehicle, seat.index) else - enterVehicleSeat(vehicle, seat.index) + if isVehicleBoat then + teleportToSeat(vehicle, seat.index) + else + enterVehicleSeat(vehicle, seat.index) + end end end }) @@ -190,9 +255,10 @@ local function showSeatMenu(vehicle) -- Belegte Sitze anzeigen if #occupiedSeats > 0 then + local headerText = isVehicleBoat and '🔴 Belegte Plätze' or '🔴 Belegte Sitze' table.insert(options, { - title = '🔴 Belegte Sitze', - description = 'Bereits besetzte Sitzplätze', + title = headerText, + description = isVehicleBoat and 'Bereits besetzte Plätze' or 'Bereits besetzte Sitzplätze', disabled = true }) @@ -208,13 +274,16 @@ local function showSeatMenu(vehicle) -- Aussteigen Option (nur wenn im Fahrzeug) if isInVehicle then + local exitText = isVehicleBoat and '🚪 Von Bord gehen' or '🚪 Aussteigen' + local exitDesc = isVehicleBoat and 'Das Boot verlassen' or 'Das Fahrzeug verlassen' table.insert(options, { - title = '🚪 Aussteigen', - description = 'Das Fahrzeug verlassen', + title = exitText, + description = exitDesc, icon = 'fas fa-door-open', onSelect = function() TaskLeaveVehicle(playerPed, vehicle, 0) - QBCore.Functions.Notify('Du steigst aus dem Fahrzeug aus...', 'primary') + local exitMsg = isVehicleBoat and 'Du gehst von Bord...' or 'Du steigst aus dem Fahrzeug aus...' + QBCore.Functions.Notify(exitMsg, 'primary') end }) end @@ -236,7 +305,7 @@ local function showSeatMenu(vehicle) lib.registerContext({ id = 'vehicle_seat_menu', - title = '🚗 ' .. vehicleLabel, + title = vehicleLabel, options = options }) @@ -255,48 +324,54 @@ function showVehicleInfo(vehicle) local maxSeats = GetVehicleMaxNumberOfPassengers(vehicle) + 1 -- +1 für Fahrer local engineHealth = math.floor(GetVehicleEngineHealth(vehicle) / 10) local bodyHealth = math.floor(GetVehicleBodyHealth(vehicle) / 10) - local fuelLevel = math.floor(GetVehicleFuelLevel(vehicle)) + local isVehicleBoat = isBoat(vehicle) local options = { { - title = 'Fahrzeug: ' .. vehicleLabel, + title = (isVehicleBoat and 'Boot: ' or 'Fahrzeug: ') .. vehicleLabel, description = 'Kennzeichen: ' .. (vehicleProps.plate or 'Unbekannt'), - icon = 'fas fa-car', + icon = isVehicleBoat and 'fas fa-ship' or 'fas fa-car', disabled = true }, { - title = 'Sitzplätze: ' .. maxSeats, + title = (isVehicleBoat and 'Plätze: ' or 'Sitzplätze: ') .. maxSeats, description = 'Maximale Anzahl Personen', icon = 'fas fa-users', disabled = true }, { - title = 'Motor: ' .. engineHealth .. '%', + title = (isVehicleBoat and 'Motor: ' or 'Motor: ') .. engineHealth .. '%', description = 'Zustand des Motors', icon = 'fas fa-cog', disabled = true }, { - title = 'Karosserie: ' .. bodyHealth .. '%', - description = 'Zustand der Karosserie', - icon = 'fas fa-car-crash', + title = (isVehicleBoat and 'Rumpf: ' or 'Karosserie: ') .. bodyHealth .. '%', + description = isVehicleBoat and 'Zustand des Rumpfes' or 'Zustand der Karosserie', + icon = isVehicleBoat and 'fas fa-ship' or 'fas fa-car-crash', disabled = true - }, - { + } + } + + -- Kraftstoff nur für Nicht-Boote (Boote haben oft keinen Kraftstoff-Wert) + if not isVehicleBoat then + local fuelLevel = math.floor(GetVehicleFuelLevel(vehicle)) + table.insert(options, { title = 'Kraftstoff: ' .. fuelLevel .. '%', description = 'Aktueller Tankstand', icon = 'fas fa-gas-pump', disabled = true - }, - { - title = '← Zurück', - description = 'Zurück zum Sitzmenü', - icon = 'fas fa-arrow-left', - onSelect = function() - showSeatMenu(vehicle) - end - } - } + }) + end + + table.insert(options, { + title = '← Zurück', + description = 'Zurück zum Sitzmenü', + icon = 'fas fa-arrow-left', + onSelect = function() + showSeatMenu(vehicle) + end + }) lib.registerContext({ id = 'vehicle_info_menu',