1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-07-29 09:20:46 +02:00
parent 78ebac3632
commit 53510967cf

View file

@ -248,6 +248,16 @@ RegisterNetEvent('vending:client:openOwnerMenu', function(data)
openManagersMenu(coords)
end
})
-- Add sell option only for owner
table.insert(options, {
title = 'Automaten verkaufen',
description = 'Verkaufe den Automaten für ' .. math.floor(Config.VendingMachinePrice * Config.SellBackPercentage / 100) .. '$',
icon = 'fas fa-dollar-sign',
onSelect = function()
sellVendingMachine(coords, machine.id)
end
})
end
lib.registerContext({
@ -260,6 +270,22 @@ RegisterNetEvent('vending:client:openOwnerMenu', function(data)
end, coords)
end)
-- Funktion zum Verkaufen des Automaten
function sellVendingMachine(coords, machineId)
local input = lib.inputDialog('Automaten verkaufen', {
{
type = 'checkbox',
label = 'Bestätigen',
description = 'Du erhältst ' .. math.floor(Config.VendingMachinePrice * Config.SellBackPercentage / 100) .. '$ zurück. Diese Aktion kann nicht rückgängig gemacht werden!',
required = true
}
})
if input and input[1] then
TriggerServerEvent('vending:server:sellMachine', coords, machineId)
end
end
-- Open price menu
function openPriceMenu(coords)
QBCore.Functions.TriggerCallback('vending:server:getStashItems', function(items)
@ -603,78 +629,3 @@ 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)