forked from Simnation/Main
Update client.lua
This commit is contained in:
parent
78ebac3632
commit
53510967cf
1 changed files with 26 additions and 75 deletions
|
@ -248,6 +248,16 @@ RegisterNetEvent('vending:client:openOwnerMenu', function(data)
|
||||||
openManagersMenu(coords)
|
openManagersMenu(coords)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
lib.registerContext({
|
lib.registerContext({
|
||||||
|
@ -260,6 +270,22 @@ RegisterNetEvent('vending:client:openOwnerMenu', function(data)
|
||||||
end, coords)
|
end, coords)
|
||||||
end)
|
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
|
-- Open price menu
|
||||||
function openPriceMenu(coords)
|
function openPriceMenu(coords)
|
||||||
QBCore.Functions.TriggerCallback('vending:server:getStashItems', function(items)
|
QBCore.Functions.TriggerCallback('vending:server:getStashItems', function(items)
|
||||||
|
@ -603,78 +629,3 @@ RegisterCommand('vendingdebug', function()
|
||||||
end
|
end
|
||||||
end, coords)
|
end, coords)
|
||||||
end, false)
|
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)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue