mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-16 22:06:02 +01:00
Fix Invoices not going to society accounts
This commit is contained in:
19
server.lua
19
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)
|
||||
Reference in New Issue
Block a user