Bug Fixes

This commit is contained in:
jimathy
2022-04-24 11:06:12 +01:00
committed by GitHub
parent 41c8e3698e
commit d32b191689
4 changed files with 11 additions and 19 deletions

View File

@@ -2,7 +2,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
local onDuty = false
local BankPed = nil
local BankPed = {}
RegisterNetEvent('QBCore:Client:OnPlayerLoaded') AddEventHandler('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end)
RegisterNetEvent('QBCore:Client:OnJobUpdate') AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end)
RegisterNetEvent('QBCore:Client:SetDuty') AddEventHandler('QBCore:Client:SetDuty', function(duty) onDuty = duty end)
@@ -11,16 +11,15 @@ RegisterNetEvent('QBCore:Client:OnGangUpdate') AddEventHandler('QBCore:Client:On
--Keeps track of duty on script restarts
AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang onDuty = PlayerJob.onduty end) end end)
Citizen.CreateThread(function()
CreateThread(function()
local jobroles = {}
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
--exports['qb-target']:AddBoxZone("JimBank", Config.CashInLocation, 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=Config.Debug, minZ = 105.75, maxZ = 107.29, },
exports['qb-target']:AddCircleZone("JimBank", vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 2.0, { name="JimBank", debugPoly=Config.Debug, useZ=true, },
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 })
if Config.Peds then
local i = math.random(1, #Config.PedPool)
RequestModel(Config.PedPool[i]) while not HasModelLoaded(Config.PedPool[i]) do Wait(0) end
if BankPed == nil then BankPed = CreatePed(0, Config.PedPool[i], Config.CashInLocation, Config.CashInLocation[4], false, false) end
if not BankPed[1] then BankPed[1] = CreatePed(0, Config.PedPool[i], vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z-1), Config.CashInLocation[4], false, false) end
if Config.Debug then print("Ped Created for Ticket Trade") end
end
end)
@@ -57,8 +56,9 @@ RegisterNetEvent('jim-payments:client:Charge', function(data)
end)
RegisterNetEvent('jim-payments:Tickets:Menu', function()
local amount = nil
local amount = 0
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end) amount = Citizen.Await(p)
if amount == 0 or amount == nil then TriggerEvent("QBCore:Notify", "You don't have any tickets to trade", "error") return end
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
else exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },
@@ -70,7 +70,7 @@ RegisterNetEvent('jim-payments:Tickets:Menu', function()
end)
RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billtype, img, billerjob)
if img == nil then img = "" end
if not img then img = "" end
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = img.."🧾 "..billerjob.." Payment 🧾", txt = "Do you want accept the payment?" },
{ isMenuHeader = true, header = "", txt = billtype:gsub("^%l", string.upper).." Payment: $"..amount },
@@ -82,5 +82,5 @@ RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent(
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then exports['qb-target']:RemoveZone("JimBank") DeletePed(BankPed) end
if resource == GetCurrentResourceName() then exports['qb-target']:RemoveZone("JimBank") DeletePed(BankPed[1]) end
end)