local ESX = exports['es_extended']:getSharedObject() local function OpenInvoiceMenu() local playerData = ESX.GetPlayerData() if playerData.job == nil or playerData.job.name ~= Config.Job then ESX.ShowNotification('Nimaš dostopa do izdaje računov.') return end if lib == nil then ESX.ShowNotification('ox_lib ni naložen. Preveri fxmanifest in vrstni red v server.cfg.') return end -- Poberi seznam blizjih oseb (prikaze se samo ime in priimek, brez ID-ja) local myCoords = GetEntityCoords(PlayerPedId()) local nearby = lib.callback.await('amirkebab_invoice:getNearby', false, myCoords) local customerOptions = {} for _, p in ipairs(nearby) do customerOptions[#customerOptions + 1] = { value = tostring(p.serverId), label = p.label, -- "Ime Priimek" - brez ID-ja } end if #customerOptions == 0 then customerOptions[1] = { value = '', label = 'Ni oseb v bližini', disabled = true } end local input = lib.inputDialog('Izdaja računa', { { type = 'input', label = 'Razlog (reason)', placeholder = Config.DefaultLabel, required = true }, { type = 'number', label = 'Znesek (€)', required = true, min = 1 }, { type = 'select', label = 'Stranka', options = customerOptions, required = false }, }) if not input then -- uporabnik je preklical vnos return end local reason = input[1] local amount = tonumber(input[2]) local target = input[3] -- serverId izbrane stranke (ali nil/prazno) if not amount or amount <= 0 then ESX.ShowNotification('Vnesi veljaven znesek.') return end if not reason or reason == '' then ESX.ShowNotification('Vnesi razlog računa.') return end TriggerServerEvent('amirkebab_invoice:create', reason, amount, target) end CreateThread(function() exports.ox_target:addBoxZone({ coords = Config.InvoicePoint, size = vec3(1.0, 1.0, 2.0), rotation = Config.Heading, debug = false, options = { { label = Config.Target.label, icon = Config.Target.icon, distance = Config.Target.distance, onSelect = function() OpenInvoiceMenu() end, canInteract = function() local playerData = ESX.GetPlayerData() return playerData.job ~= nil and playerData.job.name == Config.Job end, } } }) end) RegisterNetEvent('amirkebab_invoice:result', function(success, message) ESX.ShowNotification(message) end)