From b78c6dc3a995670932c4eebae19231edc19bcde4 Mon Sep 17 00:00:00 2001 From: jimathy Date: Sun, 6 Feb 2022 15:47:07 +0000 Subject: [PATCH] Added menu on payment The menu when cashing in receipts was added while testing stuff, I may expand it on this more --- client.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/client.lua b/client.lua index c021b91..54d00ef 100644 --- a/client.lua +++ b/client.lua @@ -1,7 +1,6 @@ local QBCore = exports['qb-core']:GetCoreObject() PlayerJob = {} - local onDuty = false RegisterNetEvent('QBCore:Client:OnPlayerLoaded') @@ -23,14 +22,14 @@ AddEventHandler('QBCore:Client:SetDuty', function(duty) end) --Keeps track of duty on script restarts -AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job onDuty = PlayerJob.onduty end) end end) +AddEventHandler('onResourceStart', function(resource) +if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job onDuty = PlayerJob.onduty end) end end) Citizen.CreateThread(function() local jobroles = {} - for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end - Wait(500) - exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=false, minZ = 105.75, maxZ = 107.29, }, - { options = { { type = 'server', event = "jim-payments:Tickets:Sell", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles }, }, + for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end + exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=true, minZ = 105.75, maxZ = 107.29, }, + { options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 }) end) @@ -51,3 +50,16 @@ RegisterNetEvent('jim-payments:client:Charge', function() end end) end) + +RegisterNetEvent('jim-payments:Tickets:Menu', function() + for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then + else exports['qb-menu']:openMenu({ + { isMenuHeader = true, header = PlayerJob.label.." Ticket Payment", txt = "Do you want trade your tickets for payment?" }, + { header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } }, + { header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, }) + end + end +end) + +RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end) +RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)