From 0afbee61e024783dce1ff5720fdbbbc088fffd4c Mon Sep 17 00:00:00 2001 From: jimathy Date: Wed, 4 May 2022 10:17:43 +0100 Subject: [PATCH] Fix Invoices not going to society accounts --- server.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server.lua b/server.lua index 35812f5..6e190dc 100644 --- a/server.lua +++ b/server.lua @@ -2,12 +2,7 @@ local QBCore = exports['qb-core']:GetCoreObject() local function cv(amount) local formatted = amount - while true do - formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') - if (k==0) then - break - end - end + while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end return formatted end @@ -19,12 +14,17 @@ end) RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller) --Find the biller from their citizenid - if biller == nil then + if not biller then for k, v in pairs(QBCore.Functions.GetPlayers()) do local Player = QBCore.Functions.GetPlayer(v) if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end end end + if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount) + if Config.Debug then print("QB-Management: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end + else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount) + if Config.Debug then print("QB-BossMenu: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end + end -- If ticket system enabled, do this if Config.TicketSystem then if data.amount >= Config.Jobs[data.society].MinAmountforTicket then @@ -62,6 +62,7 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller) end end end + end) RegisterServerEvent('jim-payments:Tickets:Sell', function() @@ -129,8 +130,6 @@ RegisterServerEvent("jim-payments:server:PayPopup", function(data) local newdata = { senderCitizenId = biller.PlayerData.citizenid, society = biller.PlayerData.job.name, amount = data.amount } if data.accept == true then billed.Functions.RemoveMoney(tostring(data.billtype), data.amount) - if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount) - else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount) end TriggerEvent('jim-payments:Tickets:Give', newdata, biller) TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the payment", "success") elseif data.accept == false then @@ -146,4 +145,4 @@ QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname } end cb(onlineList) -end) +end) \ No newline at end of file