make use of jim_bridge new banking functions

This commit is contained in:
Jim Shield
2025-03-07 13:36:24 +00:00
committed by GitHub
parent 62e8242d9e
commit 10f477982d
4 changed files with 14 additions and 302 deletions

View File

@@ -37,7 +37,7 @@ end
RegisterNetEvent(getScript()..":Client:ATM", function() local setheader = nil RegisterNetEvent(getScript()..":Client:ATM", function() local setheader = nil
--this grabs all the info from names to savings account numbers in the databases --this grabs all the info from names to savings account numbers in the databases
local info = triggerCallback(getScript()..":GetInfo") local info = triggerCallback(getScript()..":GetInfo")
jsonPrint(info)
playAnim("amb@prop_human_atm@male@enter", "enter", 2000, 1) playAnim("amb@prop_human_atm@male@enter", "enter", 2000, 1)
if progressBar({ label = locale("menu", "acc_atm"), time = 3000 }) then if progressBar({ label = locale("menu", "acc_atm"), time = 3000 }) then

View File

@@ -1,209 +0,0 @@
--[[
CreateThread(function()
local jobroles = {} local gangroles = {}
--Build Job/Gang Checks for cashin location
for k, v in pairs(Config.Jobs) do if v.gang then gangroles[tostring(k)] = 0 else jobroles[tostring(k)] = 0 end end
--Create Target at location
Targets["JimBank"] =
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 = Loc[Config.Lan].target["cashin_boss"], job = jobroles, },
{ event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = Loc[Config.Lan].target["cashin_gang"], gang = gangroles, } },
distance = 2.0 })
--Crete Ped at the location
if Config.Peds then
if not Config.Gabz then CreateModelHide(vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 1.0, `v_corp_bk_chair3`, true) end
BankPed = makePed(Config.PedPool[math.random(1, #Config.PedPool)], Config.CashInLocation, false, false)
end
--Spawn Custom Cash Register Targets
for k, v in pairs(Config.CustomCashRegisters) do
for i = 1, #v do
local job = k
local gang = nil
if v[i].gang then job = nil gang = k end
Targets["CustomRegister: "..k..i] =
exports['qb-target']:AddBoxZone("CustomRegister: "..k..i, v[i].coords.xyz, 0.47, 0.34, { name="CustomRegister: "..k..i, heading = v[i].coords[4], debugPoly=Config.Debug, minZ=v[i].coords.z-0.1, maxZ=v[i].coords.z+0.4 },
{ options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = Loc[Config.Lan].target["charge"], job = job, gang = gang, img = "" }, },
distance = 2.0 })
if v[i].prop then
Till[#Till+1] = makeProp({prop = `prop_till_03`, coords = v[i].coords}, 1, false)
end
end
end
end)
RegisterNetEvent('jim-payments:client:PolCharge', function()
--Check if player is allowed to use /cashregister command
local allowed = false
for k in pairs(Config.FineJobs) do if k == PlayerJob.name then allowed = true end end
if not allowed then triggerNotify(nil, nil, Loc[Config.Lan].error["no_job"], "error") return end
local newinputs = {} -- Begin qb-input creation here.
if Config.FineJobList then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) p:resolve(cb) end)
local onlineList = Citizen.Await(p)
local nearbyList = {}
--Convert list of players nearby into one qb-input understands + add distance info
for _, v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) then
if v ~= PlayerId() or Config.Debug then
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)', label = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
end
end
end
end
--If list is empty(no one nearby) show error and stop
if not nearbyList[1] then triggerNotify(nil, nil, Loc[Config.Lan].error["no_one"], "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, required = true, name = 'citizen', label = Loc[Config.Lan].menu["person_id"], text = Loc[Config.Lan].menu["person_id"] }
end
--Continue adding payment options to qb-input
if Config.Menu == "qb" then
newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = Loc[Config.Lan].menu["amount_charge"] }
elseif Config.Menu == "ox" then
newinputs[#newinputs+1] = {type = 'number', required = true, label = Loc[Config.Lan].menu["amount_charge"], text = Loc[Config.Lan].menu["amount_charge"] }
end
--Grab Player Job name or Gang Name if needed
local label = PlayerJob.label
local gang = false
local dialog
if Config.Menu == "qb" then
dialog = exports['qb-input']:ShowInput({ header = label..Loc[Config.Lan].menu["charge"], submitText = Loc[Config.Lan].menu["send"], inputs = newinputs})
elseif Config.Menu == "ox" then
dialog = exports.ox_lib:inputDialog(label..Loc[Config.Lan].menu["charge"], newinputs)
end
if dialog then
local inputs = {
citizen = dialog.citizen or dialog[1],
price = dialog.price or dialog[2],
}
if not inputs.citizen or not inputs.price then return end
TriggerServerEvent('jim-payments:server:PolCharge', dialog.citizen, dialog.price)
end
end)
RegisterNetEvent('jim-payments:Tickets:Menu', function(data)
--Get ticket info
local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end)
local amount = Citizen.Await(p)
if not amount then triggerNotify(nil, nil, Loc[Config.Lan].error["no_ticket"], "error") amount = 0 return else amount = amount.amount end
local sellable = false
local name = "" local label = ""
--Check/adjust for job/gang names
for k, v in pairs(Config.Jobs) do
if data.gang then if v.gang and k == PlayerGang.name then name = k label = PlayerGang.label sellable = true end
else if not v.gang and k == PlayerJob.name then name = k label = PlayerJob.label sellable = true end
end
if sellable then -- if info is found then:
if Config.Menu == "qb" then
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..label..Loc[Config.Lan].menu["receipt"], txt = Loc[Config.Lan].menu["trade_confirm"] },
{ isMenuHeader = true, header = "", txt = Loc[Config.Lan].menu["ticket_amount"]..amount..Loc[Config.Lan].menu["total_pay"]..(Config.Jobs[name].PayPerTicket * amount) },
{ icon = "fas fa-circle-check", header = Loc[Config.Lan].menu["yes"], txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
{ icon = "fas fa-circle-xmark", header = Loc[Config.Lan].menu["no"], txt = "", params = { event = "jim-payments:Tickets:Sell:no" } },
})
elseif Config.Menu == "ox" then
lib.registerContext({
id = 'ticketmenu',
title = "🧾 "..label..Loc[Config.Lan].menu["receipt"],
options = {
{ readOnly = true, title = "🧾 "..label..Loc[Config.Lan].menu["receipt"], description = Loc[Config.Lan].menu["trade_confirm"] },
{ readOnly = true, title = Loc[Config.Lan].menu["ticket_amount"]..amount..Loc[Config.Lan].menu["total_pay"]..(Config.Jobs[name].PayPerTicket * amount), description = "", txt = Loc[Config.Lan].menu["ticket_amount"]..amount..Loc[Config.Lan].menu["total_pay"]..(Config.Jobs[name].PayPerTicket * amount) },
{ icon = "fas fa-circle-check", title = Loc[Config.Lan].menu["yes"], description = "", event = "jim-payments:Tickets:Sell:yes" },
{ icon = "fas fa-circle-xmark", title = Loc[Config.Lan].menu["no"], description = "", event = "jim-payments:Tickets:Sell:no" },
}
})
lib.showContext('ticketmenu')
end
end
end
end)
RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside)
local img = img or ""
if Config.Menu == "qb" then
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = img.."🧾 "..billerjob..Loc[Config.Lan].menu["payment"], txt = Loc[Config.Lan].menu["accept_payment"] },
{ isMenuHeader = true, header = "", txt = billtype:gsub("^%l", string.upper)..Loc[Config.Lan].menu["payment_amount"]..amount },
{ icon = "fas fa-circle-check", header = Loc[Config.Lan].menu["yes"], txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = true, amount = amount, biller = biller, billtype = billtype, gang = gang, outside = outside } } },
{ icon = "fas fa-circle-xmark", header = Loc[Config.Lan].menu["no"], txt = "", params = { isServer = true, event = "jim-payments:server:PayPopup", args = { accept = false, amount = amount, biller = biller, billtype = billtype, outside = outside } } }, })
else
lib.registerContext({
id = 'paypopup',
title = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"],
options = {
{
title = billtype:gsub("^%l", string.upper)..Loc[Config.Lan].menu["payment_amount"]..amount,
icon = 'fas fa-money',
readOnly = true,
},
{
title = Loc[Config.Lan].menu["yes"],
icon = "fas fa-circle-check",
serverEvent = "jim-payments:server:PayPopup",
args = {
accept = true,
amount = amount,
biller = biller,
billtype = billtype,
gang = gang,
outside = outside
}
},
{
title = Loc[Config.Lan].menu["no"],
icon = "fas fa-circle-xmark",
serverEvent = "jim-payments:server:PayPopup",
args = {
accept = false,
amount = amount,
biller = biller,
billtype = billtype,
outside = outside
}
}
}
})
lib.showContext('paypopup')
end
end)
RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, billerjob)
if Config.Menu == "qb" then
exports['qb-menu']:openMenu({
{ isMenuHeader = true, header = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"], txt = Loc[Config.Lan].menu["accept_charge"] },
{ isMenuHeader = true, header = "", txt = Loc[Config.Lan].menu["bank_charge"]..amount },
{ icon = "fas fa-circle-check", header = Loc[Config.Lan].menu["yes"], txt = "", params = { isServer = true, event = "jim-payments:server:PolPopup", args = { accept = true, amount = amount, biller = biller } } },
{ icon = "fas fa-circle-xmark", header = Loc[Config.Lan].menu["no"], txt = "", params = { isServer = true, event = "jim-payments:server:PolPopup", args = { accept = false, amount = amount, biller = biller } } }, })
else
lib.registerContext({
id = 'polpopup',
title = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"],
options = {
{readOnly = true, title = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"], description = Loc[Config.Lan].menu["accept_charge"] },
{ readOnly = true, title = "", description = Loc[Config.Lan].menu["bank_charge"]..amount },
{ icon = "fas fa-circle-check", title = Loc[Config.Lan].menu["yes"], description = "", serverEvent = "jim-payments:server:PolPopup", args = { accept = true, amount = amount, biller = biller } },
{ icon = "fas fa-circle-xmark", title = Loc[Config.Lan].menu["no"], description = "", serverEvent = "jim-payments:server:PolPopup", args = { accept = false, amount = amount, biller = biller } },
}
})
lib.showContext('polpopup')
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)
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end
for i = 1, #Till do DeleteEntity(Till[i]) end
unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed)
end)
]]

View File

@@ -8,9 +8,11 @@ Config = {
Debug = false, Debug = false,
EventDebug = false, EventDebug = false,
Menu = "ox", -- "qb", "ox", "gta" Menu = "qb", -- "qb", "ox", "gta"
Notify = "gta", -- "qb", "ox", "gta", "esx" Notify = "gta", -- "qb", "ox", "gta", "esx"
ProgressBar = "gta", -- "qb", "ox", "gta", "esx" ProgressBar = "gta", -- "qb", "ox", "gta", "esx"
DontUseTarget = false, -- uses drawtext targets instead of alt targets
}, },
Crafting = { Crafting = {

View File

@@ -65,51 +65,16 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
triggerNotify(nil, locale("error" ,"soc_low"), "error", src) triggerNotify(nil, locale("error" ,"soc_low"), "error", src)
elseif tonumber(society) >= amount then elseif tonumber(society) >= amount then
if isStarted("Renewed-Banking") then chargeSociety(Player.job, amount)
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) 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, locale("success", "draw")..cv(amount)..locale("success", "fromthe")..Jobs[Player.job].label..locale("success" ,"account"), "success", src) triggerNotify(nil, locale("success", "draw")..cv(amount)..locale("success", "fromthe")..Jobs[Player.job].label..locale("success" ,"account"), "success", src)
end end
elseif billtype == "deposit" then elseif billtype == "deposit" then
if Player.bank < amount then triggerNotify(nil, locale("error", "nomoney_bank"), "error", src) if Player.bank < amount then triggerNotify(nil, locale("error", "nomoney_bank"), "error", src)
elseif Player.bank >= amount then elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then fundSociety(Player.job, amount)
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) 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, locale("success", "deposited")..cv(amount)..locale("success", "into")..Jobs[Player.job].label..locale("success", "account"), "success", src) triggerNotify(nil, locale("success", "deposited")..cv(amount)..locale("success", "into")..Jobs[Player.job].label..locale("success", "account"), "success", src)
end end
end end
@@ -160,15 +125,7 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
if tonumber(gsociety) < amount then if tonumber(gsociety) < amount then
triggerNotify(nil, locale("error" ,"soc_low"), "error", src) triggerNotify(nil, locale("error" ,"soc_low"), "error", src)
elseif tonumber(gsociety) >= amount then elseif tonumber(gsociety) >= amount then
if isStarted("Renewed-Banking") then chargeSociety(Player.gang, amount)
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 end
fundPlayer(amount, "bank", src) fundPlayer(amount, "bank", src)
@@ -178,16 +135,8 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
if Player.bank < amount then if Player.bank < amount then
triggerNotify(nil, locale("error" ,"nomoney_bank"), "error", src) triggerNotify(nil, locale("error" ,"nomoney_bank"), "error", src)
elseif Player.bank >= amount then elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then fundSociety(Player.gang, amount)
exports['Renewed-Banking']:addAccountMoney(Player.gang, amount) chargePlayer(amount, "bank", Player.source) Wait(1500)
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, locale("success" ,"deposited")..cv(amount)..locale("success" ,"into")..Gangs[Player.gang].label..locale("success" ,"account"), "success", src) triggerNotify(nil, locale("success" ,"deposited")..cv(amount)..locale("success" ,"into")..Gangs[Player.gang].label..locale("success" ,"account"), "success", src)
end end
end end
@@ -209,10 +158,7 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query}) local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then if result[1] then
local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.gang.name), amount) chargeSociety(Player.PlayerData.gang.nameg, 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 not Reciever then if not Reciever then
Reciever.Functions.AddMoney('bank', amount) Reciever.Functions.AddMoney('bank', amount)
triggerNotify(nil, locale("success" ,"sent")..amount..locale("success" ,"to")..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src) triggerNotify(nil, locale("success" ,"sent")..amount..locale("success" ,"to")..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
@@ -265,36 +211,9 @@ createCallback(getScript()..":GetInfo", function(source)
local Player = getPlayer(source) local Player = getPlayer(source)
local society, gsociety = 0, 0 local society, gsociety = 0, 0
if isStarted("Renewed-Banking") then society = getSocietyAccount(Player.job)
society = exports["Renewed-Banking"]:getAccountMoney(Player.job) if Player.gang ~= "none" then
if Player.gang ~= "none" then gsociety = getSocietyAccount(Player.gang)
gsociety = exports["Renewed-Banking"]:getAccountMoney(Player.gang)
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
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
elseif isStarted("okokBanking") then
society = exports["okokBanking"]:GetAccount(Player.job)
if Player.gang ~= "none" then
gsociety = exports["okokBanking"]:GetAccount(Player.gang)
end
end end
-- Savings account is only QBCore for now -- Savings account is only QBCore for now