Update 3.0 beta

This commit is contained in:
Jim Shield
2025-02-21 13:54:49 +00:00
parent 38f360fc26
commit 2ebfeff554
12 changed files with 624 additions and 513 deletions

View File

@@ -1,49 +1,60 @@
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
Core.Commands.Add("cashgive",
Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent(getScript()..":client:ATM:give", source) end)
registerCommand("polcharge", {
Loc[Config.Lan].command["pay_user"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:ATM:give", source)
end
})
RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety)
local src = source
local Player = Core.Functions.GetPlayer(src)
local cashB = Player.Functions.GetMoney("cash")
local bankB = Player.Functions.GetMoney("bank")
local Player = getPlayer(src)
local amount = tonumber(amount)
local bankScript, newAmount = "", 0
--Simple transfers from bank to wallet --
if account == "bank" or account == "atm" then
if billtype == "withdraw" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
elseif bankB >= tonumber(amount) then
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
elseif Player.bank >= tonumber(amount) then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["from_bank"], "success") -- Don't really need this as phone gets notified when money is withdrawn
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
Player.Functions.AddMoney('cash', amount)
chargePlayer(amount, "bank", src) Wait(1500)
fundPlayer(amount, "cash", src)
end
elseif billtype == "deposit" then
if cashB < amount then triggerNotify(nil, Loc[Config.Lan].error["no_cash"], "error", src)
elseif cashB >= amount then
Player.Functions.RemoveMoney('cash', amount) Wait(1500)
Player.Functions.AddMoney('bank', amount)
if Player.cash < amount then
triggerNotify(nil, Loc[Config.Lan].error["no_cash"], "error", src)
elseif Player.cash >= amount then
chargePlayer(amount, "cash", src) Wait(1500)
fundPlayer(amount, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into_bank"], "success", src)
end
end
-- Transfers from bank to savings account --
elseif account == "savings" then
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
if getSavingsAccount[1] ~= nil then savbal = tonumber(getSavingsAccount[1].account_balance) aid = getSavingsAccount[1].citizenid end
if billtype == "withdraw" then
if savbal >= amount then
savbal -= amount
Player.Functions.AddMoney('bank', amount)
fundPlayer(amount, "cash", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["draw_save"], "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.PlayerData.citizenid}, function(success)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
if success then return true else return false end
end)
elseif savbal < amount then
triggerNotify(nil, Loc[Config.Lan].error["saving_low"], "error")
end
elseif billtype == "deposit" then
if amount < bankB then
if amount < Player.bank then
savbal += amount
Player.Functions.RemoveMoney('bank', amount)
chargePlayer(amount, "bank", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["depos_save"], "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.PlayerData.citizenid}, function(success)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
if success then return true else return false end
end)
else triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
@@ -52,27 +63,60 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
--Simple transfers from society account to bank --
elseif account == "society" then
if billtype == "withdraw" then
if tonumber(society) < amount then triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
if tonumber(society) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
elseif tonumber(society) >= amount then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Player.PlayerData.job.label..Loc[Config.Lan].success["account"], "success", src)
Player.Functions.AddMoney('bank', amount)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount) end
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports['Renewed-Banking']:removeAccountMoney(Player.job, amount)
newAmount = exports["Renewed-Banking"]:getAccountMoney(Player.job)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:RemoveMoney(Player.job, amount)
newAmount = exports["qb-banking"]:GetAccountBalance(Player.job)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
exports["fd_banking"]:RemoveMoney(Player.job, amount)
newAmount = exports["fd_banking"]:GetAccount(Player.job)
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:RemoveMoney(Player.job, amount)
newAmount = exports['okokBanking']:GetAccount(Player.job)
end
fundPlayer(amount, "bank", src)
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Removing ^7$"..amount.." ^2from account ^7'^6"..Player.job.."^7' ($"..newAmount..")")
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Jobs[Player.job].label..Loc[Config.Lan].success["account"], "success", src)
end
elseif billtype == "deposit" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif bankB >= amount then
if Config.Banking == "renewed" then exports['Renewed-Banking']:addAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:AddMoney(tostring(Player.PlayerData.job.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Player.PlayerData.job.label..Loc[Config.Lan].success["account"], "success", src)
if Player.bank < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports['Renewed-Banking']:addAccountMoney(Player.job, amount)
newAmount = exports["Renewed-Banking"]:getAccountMoney(Player.job)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(Player.job, amount)
newAmount = exports["qb-banking"]:GetAccountBalance(Player.job)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
exports.fd_banking:AddMoney(Player.job, amount)
newAmount = exports["fd_banking"]:GetAccount(Player.job)
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(Player.job, amount)
newAmount = exports['okokBanking']:GetAccount(Player.job)
end
chargePlayer(amount, "bank", src) Wait(1500)
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Adding ^7$"..amount.." ^2to account ^7'^6"..Player.job.."^7' ($"..newAmount..")")
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Jobs[Player.job].label..Loc[Config.Lan].success["account"], "success", src)
end
end
-- Transfer from boss account to players --
--[[ disabled until i work out a system for other frameworks
elseif account == "societytransfer" then
local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount)
@@ -90,10 +134,15 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then
local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount) end
if Config.Banking == "renewed" then
exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then
exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then
exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then
exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
end
if Reciever then
Reciever.Functions.AddMoney('bank', amount)
triggerNotify(nil, Loc[Config.Lan].success["sent"]..amount..Loc[Config.Lan].success["to"]..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
@@ -105,29 +154,43 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
elseif not result[1] then triggerNotify(nil, Loc[Config.Lan].error["error_start"]..baccount..Loc[Config.Lan].error["error_end"], "error", src)
end
end
end]]
--Simple transfers from gang society account to bank --
elseif account == "gang" then
if billtype == "withdraw" then
if tonumber(gsociety) < amount then triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
if tonumber(gsociety) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
elseif tonumber(gsociety) >= amount then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Player.PlayerData.gang.label..Loc[Config.Lan].success["account"], "success", src)
Player.Functions.AddMoney('bank', amount)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) end
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:removeAccountMoney(Player.gang, amount)
elseif isStarted("qb-banking") then
exports["qb-banking"]:RemoveMoney(Player.gang, amount)
elseif isStarted("fd_banking") then
exports["fd_banking"]:RemoveGangMoney(Player.gang, amount)
elseif isStarted("okokBanking") then
exports["okokBanking"]:RemoveMoney(Player.gang, amount)
end
end
fundPlayer(amount, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Gangs[Player.gang].label..Loc[Config.Lan].success["account"], "success", src)
elseif billtype == "deposit" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif bankB >= amount then
if Config.Banking == "rewnewed" then exports['Renewed-Banking']:addAccountMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:AddGangMoney(tostring(Player.PlayerData.gang.name), amount) end
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:addAccountMoney(Player.gang, amount)
elseif isStarted("qb-banking") then
exports["qb-banking"]:AddGangMoney(Player.gang, amount)
elseif isStarted("fd_banking") then
exports["fd_banking"]:AddGangMoney(Player.gang, amount)
elseif isStarted("okokBanking") then
exports["okokBanking"]:AddMoney(Player.gang, amount)
end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Player.PlayerData.gang.label..Loc[Config.Lan].success["account"], "success", src)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Gangs[Player.gang].label..Loc[Config.Lan].success["account"], "success", src)
end
end
-- Transfer from gang account to players --
@@ -200,68 +263,69 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
end)
createCallback('jim-payments:GetInfo', function(source, cb)
local Player = Core.Functions.GetPlayer(source)
local name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
local cid = Player.PlayerData.citizenid.." ["..source.."]"
local cash = Player.Functions.GetMoney("cash")
local bank = Player.Functions.GetMoney("bank")
local account = Player.PlayerData.charinfo.account
local society = 0
local gsociety = 0
createCallback(getScript()..":GetInfo", function(source)
local Player = getPlayer(source)
local society, gsociety = 0, 0
if Config.General.Banking == "qb-banking" then
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts')
for _, v in pairs(result) do
if Player.PlayerData.job.name == v.account_name then society = v.account_balance end
if isStarted("Renewed-Banking") then
society = exports["Renewed-Banking"]:getAccountMoney(Player.job)
if Player.gang ~= "none" then
gsociety = exports["Renewed-Banking"]:getAccountMoney(Player.gang)
end
if Player.PlayerData.gang.name ~= "none" then
for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.account_name then gsociety = v.account_balance end
elseif isStarted("qb-banking") then
if not exports["qb-banking"]:GetAccount(Player.job) then
print("Making new bank account in qb-banking for "..Player.job)
exports["qb-banking"]:CreateJobAccount(Player.job, 0) Wait(150) -- make new account if return "null"
end
society = exports["qb-banking"]:GetAccountBalance(Player.job)
if Player.gang ~= "none" then
if not exports["qb-banking"]:GetAccount(Player.gang) then
print("Making new bank account in qb-banking for "..Player.gang)
exports["qb-banking"]:CreateGangAccount(Player.gang, 0) Wait(150) -- make new account if return "null"
society = exports["qb-banking"]:GetAccountBalance(Player.gang)
end
society = exports["qb-banking"]:GetAccountBalance(Player.gang)
end
-- If qb-management, grab info directly from database
elseif not Config.General.Banking == "renewed" then
local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
for _, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end
elseif isStarted("fd_banking") then
society = exports["fd_banking"]:GetAccount(Player.job)
if Player.gang ~= "none" then
gsociety = exports["fd_banking"]:GetGangAccount(Player.gang)
end
if Player.PlayerData.gang.name ~= "none" then
for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end
elseif isStarted("okokBanking") then
society = exports["okokBanking"]:GetAccount(Player.job)
if Player.gang ~= "none" then
gsociety = exports["okokBanking"]:GetAccount(Player.gang)
end
else
end
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
if result[1] then
accountID = result[1].citizenid
savingBalance = result[1].account_balance
else
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, account_name, account_balance) VALUES (?, ?, ?)', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, 0}, function() completed = true end) repeat Wait(0) until completed == true
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, account_name, account_balance) VALUES (?, ?, ?)', { Player.citizenId, 'Savings_'..Player.citizenId, 0}, function() completed = true end) repeat Wait(0) until completed == true
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
accountID = result[1].citizenid
savingBalance = result[1].account_balance
end
local retTable = {name = name,
cash = cash,
bank = bank,
account = account,
cid = cid,
savbal = savingBalance,
aid = accountID,
society = society,
gsociety = gsociety}
if GetResourceState(OXLibExport):find("start") then return retTable
else return cb(retTable) end
local retTable = {
name = Player.firstname..' '..Player.lastname,
cash = Player.cash,
bank = Player.bank,
account = Player.account,
cid = Player.citizenId.." ["..source.."]",
savbal = savingBalance,
aid = accountID,
society = society,
gsociety = gsociety
}
return retTable
end)
Core.Commands.Add("cashgive", Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)
RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
local Player = Core.Functions.GetPlayer(source)
local Reciever = Core.Functions.GetPlayer(tonumber(citizen))
local amount = tonumber(price)

View File

@@ -1,214 +1,104 @@
AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end
onResourceStart(function()
for k in pairs(Config.Receipts.Jobs) do
while not Jobs do Wait(10) end
if not Jobs[k] and not Gangs[k] then
print("Jim-Payments: Config.Receipts.Jobs searched for job/gang '"..k.."' and couldn't find it in the Shared")
debugPrint("^1Error^7: ^5Config^7.^5Receipts^7.^5Jobs ^2searched for job/gang ^7'^3"..k.."^7' ^2and couldn't find it in the Shared^7")
end
end
end)
registerCommand("cashregister", { Loc[Config.Lan].command["cash_reg"], {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, {}, true) end })
if Items and not Items["payticket"] then
debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7")
end
end, true)
createCallback('jim-payments:MakePlayerList', function(source, cb)
registerCommand("cashregister", {
Loc[Config.Lan].command["cash_reg"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end
})
createCallback(getScript()..":MakePlayerList", function(source)
local onlineList = {}
for _, v in pairs(Core.Functions.GetPlayers()) do
for _, v in pairs(GetPlayers()) do
local Player = getPlayer(v)
onlineList[#onlineList+1] = {
value = tonumber(v),
text = "["..v.."] - "..Player.name
}
end
if GetResourceState(OXLibExport):find("start") then return onlineList
else cb(onlineList) end
return onlineList
end)
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang)
print(citizen, price, billtype, img, outside, gang)
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
local src = source
local biller = Core.Functions.GetPlayer(src)
local billed = Core.Functions.GetPlayer(tonumber(citizen))
local biller = getPlayer(src)
local billed = getPlayer(tonumber(citizen))
local amount = tonumber(price)
local balance = billed.Functions.GetMoney(billtype)
local balance = billed[billtype]
if amount and amount > 0 then
if balance < amount then
triggerNotify(nil, Loc[Config.Lan].error["customer_nocash"], "error", src)
triggerNotify(nil, Loc[Config.Lan].error["you_nocash"], "error", tonumber(citizen))
return
end
local label = biller.PlayerData.job.label
if gang == true then label = biller.PlayerData.gang.label end
local label = gang == true and Gangs[biller.gang].label or Jobs[biller.job].label
if Config.General.PhoneBank == false or gang == true or billtype == "cash" then
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img, label, gang, outside)
TriggerClientEvent(getScript()..":client:PayPopup", billed.source, amount, src, billtype, img, label, gang, outside)
else
if Config.General.PhoneType == "qb" then
MySQL.Async.insert(
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid}, function(id)
{billed.citizenid, amount, biller.job, biller.firstname, biller.citizenid}, function(id)
if id then
TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.PlayerData.source, id, biller.PlayerData.charinfo.firstname, biller.PlayerData.job.name, biller.PlayerData.citizenid, amount, GetInvokingResource())
TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.source, id, biller.firstname, biller.job, biller.citizenid, amount, GetInvokingResource())
end
end)
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
TriggerClientEvent('qb-phone:RefreshPhone', billed.source)
elseif Config.General.PhoneType == "gks" then
MySQL.Async.execute('INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', {
['@citizenid'] = billed.PlayerData.citizenid,
['@citizenid'] = billed.citizenid,
['@amount'] = amount,
['@society'] = biller.PlayerData.job.name,
['@sender'] = biller.PlayerData.charinfo.firstname,
['@sendercitizenid'] = biller.PlayerData.citizenid,
['@label'] = biller.PlayerData.job.label,
['@society'] = biller.job,
['@sender'] = biller.firstname,
['@sendercitizenid'] = biller.citizenid,
['@label'] = label,
})
TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = Loc[Config.Lan].success["inv_succ"], img= '/html/static/img/icons/logo.png' })
TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' })
TriggerClientEvent('gksphone:notifi', billed.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' })
end
triggerNotify(nil, Loc[Config.Lan].success["inv_succ"], 'success', src)
triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.source)
end
else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end
end)
RegisterServerEvent("jim-payments:server:PayPopup", function(data)
RegisterServerEvent(getScript()..":server:PayPopup", function(data)
local src = source
local billed = Core.Functions.GetPlayer(src)
local biller = Core.Functions.GetPlayer(tonumber(data.biller))
local billed = getPlayer(src)
local biller = getPlayer(tonumber(data.biller))
local newdata = {
senderCitizenId = biller.PlayerData.citizenid,
society = data.gang and biller.PlayerData.gang.name or biller.PlayerData.job.name,
senderCitizenId = biller.citizenid,
society = data.gang and biller.gang or biller.job,
amount = data.amount
}
if data.accept then
billed.Functions.RemoveMoney(tostring(data.billtype), data.amount)
if Config.General.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", data.amount) end
TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang)
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller)
chargePlayer(data.amount, data.billtype, src)
if Config.General.ApGov then
exports['ap-government']:chargeCityTax(billed.source, "Item", data.amount)
end
TriggerEvent(getScript()..":Tickets:Give", newdata, biller, data.gang)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller)
elseif not data.accept then
triggerNotify(nil, Loc[Config.Lan].success["declined"], "error", src)
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller)
end
end)
RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang) local src = source
local billed = Core.Functions.GetPlayer(src) -- This should always be from the person who accepted the payment
local takecomm = math.floor(data.amount * Config.Receipts.Jobs[data.society].Commission)
if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here
local billerGang, billerJob, amountChange, newAmount = tostring(biller.PlayerData.gang.name), tostring(biller.PlayerData.job.name), (data.amount - takecomm), 0
if gang then
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(billerGang, amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(billerGang)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange)
newAmount = exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange)
if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddGangMoney(billerGang, amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(billerGang)
elseif Config.General.Banking == "okok" then
exports['okokBanking']:AddMoney(billerGang, amountChange)
newAmount = exports['okokBanking']:GetAccount(billerGang)
end
elseif not gang then
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(billerJob, amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(billerJob)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddMoney(billerJob, amountChange)
newAmount = exports[Config.General.Banking]:GetAccount(billerJob, amountChange)
if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddMoney(billerJob, amountChange)
newAmount = exports["fd_banking"]:GetAccount(billerJob)
elseif Config.General.Banking == "okok" then
exports['okokBanking']:AddMoney(billerJob, amountChange)
newAmount = exports['okokBanking']:GetAccount(billerJob)
end
end
print("^5Debug^7: ^3"..Config.General.Banking.."^7(^3"..(gang and "Gang" or "Job").."^7): ^2Adding ^7$"..amountChange.." ^2to account ^7'^6"..(gang and billerGang or billerJob).."^7' ($"..newAmount..")")
if Config.System.Debug then
end
elseif not biller then --Find the biller from their citizenid
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
end
triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.PlayerData.source)
end
-- If ticket system enabled, do this
if (biller.PlayerData.job.onduty or gang) and Config.Receipts.TicketSystem then
if data.amount >= Config.Receipts.Jobs[data.society].MinAmountforTicket then
if Config.Receipts.TicketSystemAll then
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player ~= nil or Player ~= billed then
if gang then
if Player.PlayerData.gang.name == data.society then
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source)
end
else
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source)
end
end
end
end
else
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, biller.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.PlayerData.source)
end
end
end
-- Commission section, does each config option separately
local comm = tonumber(Config.Receipts.Jobs[data.society].Commission)
if Config.Receipts.Commission and comm ~= 0 then
if Config.Receipts.CommissionLimit and data.amount < Config.Receipts.Jobs[data.society].MinAmountforTicket then return end
if Config.Receipts.CommissionDouble then
biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2)))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source)
else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source)
end
if Config.Receipts.CommissionAll then
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player and Player ~= biller then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.PlayerData.source)
end
end
end
end
end
end)
RegisterServerEvent('jim-payments:Tickets:Sell', function()
local Player = Core.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName("payticket") then triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', source) return
else
tickets = Player.Functions.GetItemByName("payticket").amount
Player.Functions.RemoveItem('payticket', tickets)
pay = (tickets * Config.Receipts.Jobs[Player.PlayerData.job.name].PayPerTicket)
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
TriggerClientEvent('inventory:client:ItemBox', source, Core.Shared.Items['payticket'], "remove", tickets)
triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', source)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller)
end
end)
CreateThread(function()
if Config.Usebzzz then
Core.Functions.CreateUseableItem('terminal', function(source, item)
TriggerClientEvent("jim-payments:client:Charge", source, {}, true)
if Config.General.Usebzzz then
createUseableItem('terminal', function(source, item)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end)
end
end)

View File

@@ -1,14 +1,19 @@
registerCommand("polcharge", { Loc[Config.Lan].command["charge"], {}, false, function(source) TriggerClientEvent("jim-payments:client:PolCharge", source) end })
registerCommand("polcharge", {
Loc[Config.Lan].command["charge"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:PolCharge", source)
end
})
RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local src = source
local biller = Core.Functions.GetPlayer(src)
local billed = Core.Functions.GetPlayer(tonumber(citizen))
local biller = getPlayer(src)
local billed = getPlayer(tonumber(citizen))
local price = math.floor(tonumber(price))
local commPercent = Config.PolCharge.FineJobs[biller.PlayerData.job.name] and Config.PolCharge.FineJobs[biller.PlayerData.job.name].Commission or 0.25
if Config.PolCharge.FineJobs[biller.PlayerData.job.name] then
commPercent = Config.PolCharge.FineJobs[biller.PlayerData.job.name].Commission
local commPercent = Config.PolCharge.FineJobs[biller.job] and Config.PolCharge.FineJobs[biller.job].Commission or 0.25
if Config.PolCharge.FineJobs[biller.job] then
commPercent = Config.PolCharge.FineJobs[biller.job].Commission
else
commPercent = 0.25
print("Can't find job in 'FineJobs', defaulting to 0.25 (25% commission)")
@@ -22,22 +27,22 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
billed = billed,
price = price,
commission = commission,
billerJob = tostring(biller.PlayerData.job.name),
billerJob = tostring(biller.job),
amountChange = (price - commission)
})
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["charged"]..(price - commission), "success", src)
triggerNotify(nil, Loc[Config.Lan].success["you_charged"]..(price - commission), nil, billed.PlayerData.source)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].success["charged"]..(price - commission), "success", src)
triggerNotify(nil, Loc[Config.Lan].success["you_charged"]..(price - commission), nil, billed.source)
else
TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, price, src, biller.PlayerData.job.label, commPercent)
TriggerClientEvent(getScript()..":client:PolPopup", billed.source, price, src, biller.job, commPercent)
end
else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end
end)
RegisterServerEvent("jim-payments:server:PolPopup", function(data)
RegisterServerEvent(getScript()..":server:PolPopup", function(data)
local src = source
local billed = Core.Functions.GetPlayer(src)
local biller = Core.Functions.GetPlayer(tonumber(data.biller))
local billed = getPlayer(src)
local biller = getPlayer(tonumber(data.biller))
local price = math.floor(data.amount)
local commission = math.floor(tonumber(data.amount) * data.commPercent)
if data.accept then
@@ -46,7 +51,7 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
billed = billed,
price = price,
commission = commission,
billerJob = tostring(biller.PlayerData.job.name),
billerJob = tostring(biller.job),
amountChange = (price - commission)
})
elseif not data.accept then
@@ -56,36 +61,43 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
end)
function polCharge(data)
local billedSource, billerSource, newAmount = data.billed.PlayerData.source, data.biller.PlayerData.source, 0
if data.billed.Functions.RemoveMoney("bank", data.price) then
if Config.System.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billedSource.."^7) ^2charged ^7$^6"..data.price.."^7") end
local billedSource, billerSource, newAmount = data.billed.source, data.biller.source, 0
local bankScript = nil
chargePlayer(data.price, "bank", billedSource)
debugPrint("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billedSource.."^7) ^2charged ^7$^6"..data.price.."^7")
if Config.ApGov then
exports['ap-government']:chargeCityTax(billedSource, "Item", data.price)
end
if Config.ApGov then exports['ap-government']:chargeCityTax(billedSource, "Item", data.price) end
if data.biller.Functions.AddMoney("bank", data.commission) then
if Config.System.Debug then
print("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..data.commission.." ^2sent to Player^7(^6"..billerSource.."^7)")
fundPlayer(data.commission, "bank", billerSource)
debugPrint("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..data.commission.." ^2sent to Player^7(^6"..billerSource.."^7)")
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports["Renewed-Banking"]:addAccountMoney(data.billerJob, data.amountChange)
newAmount = exports["Renewed-Banking"]:getAccountMoney(data.billerJob)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(data.billerJob, data.amountChange, "Cash Register Payment")
newAmount = exports["qb-banking"]:GetAccountBalance(data.billerJob)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
if gang then
exports["fd_banking"]:AddGangMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(data.billerJob)
else
exports["fd_banking"]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetAccount(data.billerJob)
end
end
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(data.billerJob, data.amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(data.billerJob)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports[Config.General.Banking]:GetAccount(data.billerJob)
if Config.General.Banking == "qb-banking" then newAmount = newAmount.account_balance end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetAccount(data.billerJob)
elseif Config.General.Banking == "okok" then
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(data.billerJob, data.amountChange)
newAmount = exports['okokBanking']:GetAccount(data.billerJob)
end
end
if Config.System.Debug then
print("^5Debug^7: ^3"..Config.General.Banking.."^7(^3Job^7): ^2Adding ^7$"..data.amountChange.." ^2to account ^7'^6"..data.billerJob.."^7' ($"..newAmount..")")
end
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Adding ^7$"..data.amountChange.." ^2to account ^7'^6"..data.billerJob.."^7' ($"..newAmount..")")
end

120
server/ticketserver.lua Normal file
View File

@@ -0,0 +1,120 @@
RegisterServerEvent(getScript()..":Tickets:Give", function(data, biller, gang)
local src = source
local activePlayers = GetPlayers()
local commPercent = 0
jsonPrint(data)
if Config.Receipts.Jobs[data.society] then
commPercent = Config.Receipts.Jobs[data.society].Commission
else commPercent = 0.25
print("^1Error^7: ^2Can't find job in ^7'^3Config^7.^3Receipts^7.^3Jobs^7', ^2defaulting to 0.25 (25% commission)^7")
end
local takecomm = math.floor(data.amount * commPercent)
if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here
local amountChange, newAmount = (data.amount - takecomm), 0
local society = gang and tostring(biller.gang) or tostring(biller.job)
local bankScript = nil
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports["Renewed-Banking"]:addAccountMoney(society, amountChange)
newAmount = exports["Renewed-Banking"]:getAccountMoney(society)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(society, amountChange, "Cash Register Payment")
newAmount = exports["qb-banking"]:GetAccountBalance(society)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
if gang then
exports["fd_banking"]:AddGangMoney(society, amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(society)
else
exports["fd_banking"]:AddMoney(society, amountChange)
newAmount = exports["fd_banking"]:GetAccount(society)
end
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(society, amountChange)
newAmount = exports['okokBanking']:GetAccount(society)
end
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3"..(gang and "Gang" or "Job").."^7): ^2Adding ^7$"..amountChange.." ^2to account ^7'^6"..society.."^7' ($"..newAmount..")")
elseif not biller then --Find the biller from their citizenid
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if Player.citizenid == data.senderCitizenId then
biller = Player
end
end
triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.source)
end
-- If ticket system enabled, do this
if (biller.onDuty or gang) and Config.Receipts.TicketSystem then
if data.amount >= Config.Receipts.Jobs[data.society].MinAmountforTicket then
if Config.Receipts.TicketSystemAll then
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if v ~= src then
if gang then
if Player.gang == data.society then
addItem("payticket", 1, nil, Player.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.source)
end
else
print("player found")
if Player.job == data.society and Player.onDuty then
print("player on duty, giving tickets")
addItem("payticket", 1, nil, Player.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.source)
end
end
end
end
else
addItem("payticket", 1, nil, biller.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.source)
end
end
end
-- Commission section, does each config option separately
local comm = tonumber(Config.Receipts.Jobs[data.society].Commission)
if Config.Receipts.Commission and comm ~= 0 then
if Config.Receipts.CommissionLimit and data.amount < Config.Receipts.Jobs[data.society].MinAmountforTicket then return end
if Config.Receipts.CommissionDouble then
fundPlayer(math.floor(tonumber(data.amount) * (comm *2)), "bank", biller.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.source)
else
fundPlayer(math.floor(tonumber(data.amount) *comm), "bank", biller.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.source)
end
if Config.Receipts.CommissionAll then
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if v ~= biller.source then
if Player.job == data.society and Player.onDuty then
fundPlayer(math.floor(tonumber(data.amount) * comm), "bank", Player.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.source)
end
end
end
end
end
end)
RegisterServerEvent(getScript()..":Tickets:Sell", function() local src = source
local Player = getPlayer(src)
local hasItem, hasTable = hasItem("payticket", 1, src)
if not hasItem then
triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', src)
return
else
local tickets = hasTable["payticket"].count
removeItem("payticket", tickets, src)
local pay = (tickets * Config.Receipts.Jobs[Player.job].PayPerTicket)
fundPlayer(pay, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', src)
end
end)