From 78ebac3632e5a35e9fe298cde7c2962288e65c8a Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Tue, 29 Jul 2025 09:13:56 +0200 Subject: [PATCH] Update client.lua --- .../[inventory]/nordi_vending/client.lua | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/resources/[inventory]/nordi_vending/client.lua b/resources/[inventory]/nordi_vending/client.lua index 3ea2e2a9d..62ba344ad 100644 --- a/resources/[inventory]/nordi_vending/client.lua +++ b/resources/[inventory]/nordi_vending/client.lua @@ -603,3 +603,78 @@ RegisterCommand('vendingdebug', function() end end, coords) end, false) + +-- Open owner menu +RegisterNetEvent('vending:client:openOwnerMenu', function(data) + local entity = data.entity + local coords = GetEntityCoords(entity) + + QBCore.Functions.TriggerCallback('vending:server:getMachineByCoords', function(machine) + if not machine then + QBCore.Functions.Notify('Automat nicht gefunden!', 'error') + return + end + + -- Debug-Ausgabe + print("Machine data:", json.encode(machine)) + print("Is owner:", machine.isOwner) + + local options = { + { + title = 'Inventar verwalten', + description = 'Items hinzufügen/entfernen', + icon = 'fas fa-box', + onSelect = function() + TriggerServerEvent('vending:server:openStash', coords) + end + }, + { + title = 'Preise festlegen', + description = 'Verkaufspreise für Items setzen', + icon = 'fas fa-tags', + onSelect = function() + openPriceMenu(coords) + end + }, + { + title = 'Geld abheben', + description = 'Verfügbar: $' .. machine.money, + icon = 'fas fa-money-bill', + onSelect = function() + openWithdrawMenu(coords, machine.money) + end + }, + { + title = 'Statistiken', + description = 'Verkaufsstatistiken anzeigen', + icon = 'fas fa-chart-bar', + onSelect = function() + openStatsMenu(machine) + end + } + } + + -- Add manager options only for owner + if machine.isOwner then + print("Adding manager option because player is owner") + table.insert(options, { + title = 'Verwalter', + description = 'Verwalter hinzufügen/entfernen', + icon = 'fas fa-users-cog', + onSelect = function() + openManagersMenu(coords) + end + }) + else + print("Not adding manager option because player is not owner") + end + + lib.registerContext({ + id = 'vending_owner_menu', + title = 'Verkaufsautomat Verwaltung', + options = options + }) + + lib.showContext('vending_owner_menu') + end, coords) +end)