1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-31 06:41:48 +02:00
parent 2504432a6e
commit 8a47b4502d
5 changed files with 343 additions and 30 deletions

View file

@ -52,7 +52,7 @@ end
-- Lade verankerte Boote vom Server -- Lade verankerte Boote vom Server
local function loadAnchoredBoats() local function loadAnchoredBoats()
QBCore.Functions.TriggerCallback('nordi_seats:server:getAnchoredBoats', function(serverAnchors) QBCore.Functions.TriggerCallback('nordi_carmenu:server:getAnchoredBoats', function(serverAnchors)
if serverAnchors then if serverAnchors then
for plate, anchorData in pairs(serverAnchors) do for plate, anchorData in pairs(serverAnchors) do
-- Finde Fahrzeug mit dieser Kennzeichen -- Finde Fahrzeug mit dieser Kennzeichen
@ -84,7 +84,7 @@ end
local function saveAnchorToServer(vehicle, anchorData) local function saveAnchorToServer(vehicle, anchorData)
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle) local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
if vehicleProps.plate then if vehicleProps.plate then
TriggerServerEvent('nordi_seats:server:saveAnchor', vehicleProps.plate, anchorData) TriggerServerEvent('nordi_carmenu:server:saveAnchor', vehicleProps.plate, anchorData)
end end
end end
@ -92,7 +92,7 @@ end
local function removeAnchorFromServer(vehicle) local function removeAnchorFromServer(vehicle)
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle) local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
if vehicleProps.plate then if vehicleProps.plate then
TriggerServerEvent('nordi_seats:server:removeAnchor', vehicleProps.plate) TriggerServerEvent('nordi_carmenu:server:removeAnchor', vehicleProps.plate)
end end
end end
@ -159,7 +159,7 @@ CreateThread(function()
-- Prüfe ob dieses Boot einen gespeicherten Anker hat -- Prüfe ob dieses Boot einen gespeicherten Anker hat
local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle) local vehicleProps = QBCore.Functions.GetVehicleProperties(vehicle)
if vehicleProps.plate then if vehicleProps.plate then
QBCore.Functions.TriggerCallback('nordi_seats:server:getAnchorByPlate', function(anchorData) QBCore.Functions.TriggerCallback('nordi_carmenu:server:getAnchorByPlate', function(anchorData)
if anchorData then if anchorData then
-- Setze Boot an gespeicherte Position -- Setze Boot an gespeicherte Position
SetEntityCoords(vehicle, anchorData.coords.x, anchorData.coords.y, anchorData.coords.z) SetEntityCoords(vehicle, anchorData.coords.x, anchorData.coords.y, anchorData.coords.z)
@ -370,8 +370,319 @@ local function switchSeat(vehicle, newSeatIndex)
end end
end end
-- Tür-Kontrollfunktion
local function controlDoor(vehicle, doorIndex)
if GetVehicleDoorAngleRatio(vehicle, doorIndex) > 0.0 then
SetVehicleDoorShut(vehicle, doorIndex, false)
QBCore.Functions.Notify('Tür geschlossen', 'success')
else
SetVehicleDoorOpen(vehicle, doorIndex, false, false)
QBCore.Functions.Notify('Tür geöffnet', 'success')
end
end
-- Fenster-Kontrollfunktion
local function controlWindow(vehicle, windowIndex)
if IsVehicleWindowIntact(vehicle, windowIndex) then
RollDownWindow(vehicle, windowIndex)
QBCore.Functions.Notify('Fenster geöffnet', 'success')
else
RollUpWindow(vehicle, windowIndex)
QBCore.Functions.Notify('Fenster geschlossen', 'success')
end
end
-- Extras-Kontrollfunktion
local function controlExtra(vehicle, extraId)
if DoesExtraExist(vehicle, extraId) then
if IsVehicleExtraTurnedOn(vehicle, extraId) then
SetVehicleExtra(vehicle, extraId, true)
QBCore.Functions.Notify('Extra ' .. extraId .. ' deaktiviert', 'success')
else
SetVehicleExtra(vehicle, extraId, false)
QBCore.Functions.Notify('Extra ' .. extraId .. ' aktiviert', 'success')
end
end
end
-- Türen-Kontrollmenü
function showDoorControlMenu(vehicle)
local options = {
{
title = '🚪 Alle Türen',
description = 'Alle Türen öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
for i = 0, 5 do
if GetVehicleDoorAngleRatio(vehicle, i) > 0.0 then
SetVehicleDoorShut(vehicle, i, false)
else
SetVehicleDoorOpen(vehicle, i, false, false)
end
end
QBCore.Functions.Notify('Alle Türen umgeschaltet', 'success')
end
},
{
title = '🚪 Fahrertür',
description = 'Fahrertür öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
controlDoor(vehicle, 0)
end
},
{
title = '🚪 Beifahrertür',
description = 'Beifahrertür öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
controlDoor(vehicle, 1)
end
},
{
title = '🚪 Hinten Links',
description = 'Hintere linke Tür öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
controlDoor(vehicle, 2)
end
},
{
title = '🚪 Hinten Rechts',
description = 'Hintere rechte Tür öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
controlDoor(vehicle, 3)
end
},
{
title = '🚪 Motorhaube',
description = 'Motorhaube öffnen/schließen',
icon = 'fas fa-car',
onSelect = function()
controlDoor(vehicle, 4)
end
},
{
title = '🚪 Kofferraum',
description = 'Kofferraum öffnen/schließen',
icon = 'fas fa-box',
onSelect = function()
controlDoor(vehicle, 5)
end
},
{
title = '← Zurück',
description = 'Zurück zum Hauptmenü',
icon = 'fas fa-arrow-left',
onSelect = function()
showVehicleControlMenu(vehicle)
end
}
}
lib.registerContext({
id = 'vehicle_door_menu',
title = '🚪 Türen steuern',
options = options
})
lib.showContext('vehicle_door_menu')
end
-- Fenster-Kontrollmenü
function showWindowControlMenu(vehicle)
local options = {
{
title = '🪟 Alle Fenster',
description = 'Alle Fenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
for i = 0, 3 do
if IsVehicleWindowIntact(vehicle, i) then
RollDownWindow(vehicle, i)
else
RollUpWindow(vehicle, i)
end
end
QBCore.Functions.Notify('Alle Fenster umgeschaltet', 'success')
end
},
{
title = '🪟 Fahrerfenster',
description = 'Fahrerfenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
controlWindow(vehicle, 0)
end
},
{
title = '🪟 Beifahrerfenster',
description = 'Beifahrerfenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
controlWindow(vehicle, 1)
end
},
{
title = '🪟 Hinten Links',
description = 'Hinteres linkes Fenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
controlWindow(vehicle, 2)
end
},
{
title = '🪟 Hinten Rechts',
description = 'Hinteres rechtes Fenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
controlWindow(vehicle, 3)
end
},
{
title = '← Zurück',
description = 'Zurück zum Hauptmenü',
icon = 'fas fa-arrow-left',
onSelect = function()
showVehicleControlMenu(vehicle)
end
}
}
lib.registerContext({
id = 'vehicle_window_menu',
title = '🪟 Fenster steuern',
options = options
})
lib.showContext('vehicle_window_menu')
end
-- Extras-Kontrollmenü
function showExtrasControlMenu(vehicle)
local options = {}
-- Prüfe welche Extras existieren
local hasExtras = false
for i = 0, 14 do
if DoesExtraExist(vehicle, i) then
hasExtras = true
local status = IsVehicleExtraTurnedOn(vehicle, i) and "Aktiviert" or "Deaktiviert"
table.insert(options, {
title = '🔧 Extra ' .. i,
description = 'Status: ' .. status,
icon = 'fas fa-puzzle-piece',
onSelect = function()
controlExtra(vehicle, i)
showExtrasControlMenu(vehicle) -- Aktualisiere Menü für aktuellen Status
end
})
end
end
if not hasExtras then
table.insert(options, {
title = 'Keine Extras verfügbar',
description = 'Dieses Fahrzeug hat keine Extras',
icon = 'fas fa-times',
disabled = true
})
end
table.insert(options, {
title = '← Zurück',
description = 'Zurück zum Hauptmenü',
icon = 'fas fa-arrow-left',
onSelect = function()
showVehicleControlMenu(vehicle)
end
})
lib.registerContext({
id = 'vehicle_extras_menu',
title = '🔧 Extras steuern',
options = options
})
lib.showContext('vehicle_extras_menu')
end
-- Hauptmenü für Fahrzeugsteuerung
function showVehicleControlMenu(vehicle)
local options = {
{
title = '🚪 Türen steuern',
description = 'Türen öffnen/schließen',
icon = 'fas fa-door-open',
onSelect = function()
showDoorControlMenu(vehicle)
end
},
{
title = '🪟 Fenster steuern',
description = 'Fenster öffnen/schließen',
icon = 'fas fa-window-maximize',
onSelect = function()
showWindowControlMenu(vehicle)
end
},
{
title = '🔧 Extras steuern',
description = 'Fahrzeug-Extras ein/ausschalten',
icon = 'fas fa-puzzle-piece',
onSelect = function()
showExtrasControlMenu(vehicle)
end
},
{
title = '👥 Sitzplätze',
description = 'Sitzplatz wechseln oder aussteigen',
icon = 'fas fa-chair',
onSelect = function()
showSeatMenu(vehicle)
end
},
{
title = '📋 Fahrzeuginfo',
description = 'Informationen über das Fahrzeug',
icon = 'fas fa-info-circle',
onSelect = function()
showVehicleInfo(vehicle)
end
}
}
-- Boot-spezifische Anker-Option
if isBoat(vehicle) then
local isAnchored = isBoatAnchored(vehicle)
local playerPed = PlayerPedId()
local currentSeat = getCurrentSeat(playerPed, vehicle)
if currentSeat == -1 then -- Nur Kapitän kann Anker bedienen
table.insert(options, 1, {
title = isAnchored and '⚓ Anker lichten' or '⚓ Anker werfen',
description = isAnchored and 'Boot wieder beweglich machen' or 'Boot an aktueller Position verankern',
icon = 'fas fa-anchor',
onSelect = function()
toggleAnchor(vehicle)
showVehicleControlMenu(vehicle) -- Aktualisiere Menü für aktuellen Status
end
})
end
end
lib.registerContext({
id = 'vehicle_control_menu',
title = '🚗 Fahrzeugsteuerung',
options = options
})
lib.showContext('vehicle_control_menu')
end
-- Hauptmenü für Sitzauswahl -- Hauptmenü für Sitzauswahl
local function showSeatMenu(vehicle) function showSeatMenu(vehicle)
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local isInVehicle = IsPedInVehicle(playerPed, vehicle, false) local isInVehicle = IsPedInVehicle(playerPed, vehicle, false)
local availableSeats = getAvailableSeats(vehicle) local availableSeats = getAvailableSeats(vehicle)
@ -474,6 +785,8 @@ local function showSeatMenu(vehicle)
description = exitDesc, description = exitDesc,
icon = 'fas fa-door-open', icon = 'fas fa-door-open',
onSelect = function() onSelect = function()
TaskLeaveVehicle(playerPed, vehicle, 0)
local exitMsg = isVehicleBoat and 'Du gehst von Bord...'
TaskLeaveVehicle(playerPed, vehicle, 0) TaskLeaveVehicle(playerPed, vehicle, 0)
local exitMsg = isVehicleBoat and 'Du gehst von Bord...' or 'Du steigst aus dem Fahrzeug aus...' local exitMsg = isVehicleBoat and 'Du gehst von Bord...' or 'Du steigst aus dem Fahrzeug aus...'
QBCore.Functions.Notify(exitMsg, 'primary') QBCore.Functions.Notify(exitMsg, 'primary')
@ -481,13 +794,13 @@ local function showSeatMenu(vehicle)
}) })
end end
-- Fahrzeuginfo -- Zurück zum Hauptmenü
table.insert(options, { table.insert(options, {
title = '📋 Fahrzeuginfo', title = '← Zurück zum Hauptmenü',
description = 'Informationen über das Fahrzeug', description = 'Zurück zur Fahrzeugsteuerung',
icon = 'fas fa-info-circle', icon = 'fas fa-arrow-left',
onSelect = function() onSelect = function()
showVehicleInfo(vehicle) showVehicleControlMenu(vehicle)
end end
}) })
@ -572,10 +885,10 @@ function showVehicleInfo(vehicle)
table.insert(options, { table.insert(options, {
title = '← Zurück', title = '← Zurück',
description = 'Zurück zum Sitzmenü', description = 'Zurück zum Hauptmenü',
icon = 'fas fa-arrow-left', icon = 'fas fa-arrow-left',
onSelect = function() onSelect = function()
showSeatMenu(vehicle) showVehicleControlMenu(vehicle)
end end
}) })
@ -594,9 +907,9 @@ CreateThread(function()
options = { options = {
{ {
type = "client", type = "client",
event = "vehicle:openSeatMenu", event = "vehicle:openControlMenu",
icon = "fas fa-car", icon = "fas fa-car",
label = "Sitzplatz wählen", label = "Fahrzeug steuern",
} }
}, },
distance = 3.0 distance = 3.0
@ -604,10 +917,10 @@ CreateThread(function()
end) end)
-- Event Handler -- Event Handler
RegisterNetEvent('vehicle:openSeatMenu', function(data) RegisterNetEvent('vehicle:openControlMenu', function(data)
local vehicle = data.entity local vehicle = data.entity
if DoesEntityExist(vehicle) and IsEntityAVehicle(vehicle) then if DoesEntityExist(vehicle) and IsEntityAVehicle(vehicle) then
showSeatMenu(vehicle) showVehicleControlMenu(vehicle)
else else
QBCore.Functions.Notify('Kein gültiges Fahrzeug gefunden!', 'error') QBCore.Functions.Notify('Kein gültiges Fahrzeug gefunden!', 'error')
end end
@ -636,18 +949,18 @@ AddEventHandler('onResourceStop', function(resourceName)
end) end)
-- Keybind für schnellen Zugriff -- Keybind für schnellen Zugriff
RegisterCommand('seats', function() RegisterCommand('carmenu', function()
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerPed, false) local vehicle = GetVehiclePedIsIn(playerPed, false)
if vehicle ~= 0 then if vehicle ~= 0 then
showSeatMenu(vehicle) showVehicleControlMenu(vehicle)
else else
local coords = GetEntityCoords(playerPed) local coords = GetEntityCoords(playerPed)
local closestVehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 71) local closestVehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 71)
if DoesEntityExist(closestVehicle) then if DoesEntityExist(closestVehicle) then
showSeatMenu(closestVehicle) showVehicleControlMenu(closestVehicle)
else else
QBCore.Functions.Notify('Kein Fahrzeug in der Nähe!', 'error') QBCore.Functions.Notify('Kein Fahrzeug in der Nähe!', 'error')
end end
@ -671,6 +984,6 @@ RegisterCommand('anchor', function()
end end
end, false) end, false)
-- Keybinds registrieren (F1 statt F6) -- Keybinds registrieren
RegisterKeyMapping('seats', 'Sitzplatz Menü öffnen', 'keyboard', 'F1') RegisterKeyMapping('carmenu', 'Fahrzeug Menü öffnen', 'keyboard', 'F1')
RegisterKeyMapping('anchor', 'Anker werfen/lichten', 'keyboard', 'H') RegisterKeyMapping('anchor', 'Anker werfen/lichten', 'keyboard', 'H')

View file

@ -2,8 +2,8 @@ fx_version 'cerulean'
game 'gta5' game 'gta5'
author 'Nordi' author 'Nordi'
description 'Fahrzeug Sitz-Auswahl Script für QBCore mit persistenten Ankern' description 'Fahrzeug Steuerungsmenü für QBCore mit Sitzen, Türen, Fenstern und Extras'
version '1.1.0' version '2.0.0'
shared_scripts { shared_scripts {
'@ox_lib/init.lua' '@ox_lib/init.lua'

View file

@ -32,7 +32,7 @@ local function removeAnchorFromDB(plate)
end end
-- Events -- Events
RegisterNetEvent('nordi_seats:server:saveAnchor', function(plate, anchorData) RegisterNetEvent('nordi_carmenu:server:saveAnchor', function(plate, anchorData)
local src = source local src = source
if not plate or not anchorData then return end if not plate or not anchorData then return end
@ -42,7 +42,7 @@ RegisterNetEvent('nordi_seats:server:saveAnchor', function(plate, anchorData)
print("^2[Anker]^7 Boot " .. plate .. " wurde verankert (Spieler: " .. src .. ")") print("^2[Anker]^7 Boot " .. plate .. " wurde verankert (Spieler: " .. src .. ")")
end) end)
RegisterNetEvent('nordi_seats:server:removeAnchor', function(plate) RegisterNetEvent('nordi_carmenu:server:removeAnchor', function(plate)
local src = source local src = source
if not plate then return end if not plate then return end
@ -53,11 +53,11 @@ RegisterNetEvent('nordi_seats:server:removeAnchor', function(plate)
end) end)
-- Callbacks -- Callbacks
QBCore.Functions.CreateCallback('nordi_seats:server:getAnchoredBoats', function(source, cb) QBCore.Functions.CreateCallback('nordi_carmenu:server:getAnchoredBoats', function(source, cb)
cb(anchoredBoats) cb(anchoredBoats)
end) end)
QBCore.Functions.CreateCallback('nordi_seats:server:getAnchorByPlate', function(source, cb, plate) QBCore.Functions.CreateCallback('nordi_carmenu:server:getAnchorByPlate', function(source, cb, plate)
cb(anchoredBoats[plate]) cb(anchoredBoats[plate])
end) end)

View file

@ -14,8 +14,8 @@ function notification(title, text, time, type)
-- Default ESX Notify: -- Default ESX Notify:
--TriggerEvent('esx:showNotification', text) --TriggerEvent('esx:showNotification', text)
-- Default QB Notify: Default QB Notify:
--TriggerEvent('QBCore:Notify', text, 'info', 5000) TriggerEvent('QBCore:Notify', text, 'info', 5000)
-- OKOK Notify: -- OKOK Notify:
-- exports['okokNotify']:Alert(title, text, time, type, false) -- exports['okokNotify']:Alert(title, text, time, type, false)

View file

@ -17,7 +17,7 @@ Config = {
TextUI = 'ox_lib', -- false / 'brutal_textui' / 'ox_lib' / 'okokTextUI' / 'ESXTextUI' / 'QBDrawText' // Custom can be add in the cl_utils.lua!!! TextUI = 'ox_lib', -- false / 'brutal_textui' / 'ox_lib' / 'okokTextUI' / 'ESXTextUI' / 'QBDrawText' // Custom can be add in the cl_utils.lua!!!
BrutalKeys = true, -- Buy here: https://store.brutalscripts.com BrutalKeys = true, -- Buy here: https://store.brutalscripts.com
BrutalPoliceJob = false, -- Buy here: https://store.brutalscripts.com | Better connection BrutalPoliceJob = false, -- Buy here: https://store.brutalscripts.com | Better connection
BrutalNotify = true, -- Buy here: (4€+VAT) https://store.brutalscripts.com | Or set up your own notify >> cl_utils.lua BrutalNotify = false, -- Buy here: (4€+VAT) https://store.brutalscripts.com | Or set up your own notify >> cl_utils.lua
SteamName = false, -- true = Steam name | false = character name SteamName = false, -- true = Steam name | false = character name
AdminGroups = {'superadmin', 'admin', 'mod', 'god'}, AdminGroups = {'superadmin', 'admin', 'mod', 'god'},