Small banking changes

This commit is contained in:
Jim Shield
2022-07-28 19:35:35 +01:00
committed by GitHub
parent d71f3d29ed
commit 2c1f1e8573
5 changed files with 99 additions and 87 deletions

View File

@@ -2,8 +2,11 @@
- QBCore based payment system - QBCore based payment system
- Enchanced QB-Input payment system from my other scripts now free on its own - Enchanced QB-Input payment system from my other scripts now free on its own
### If you need support I have a discord server available, it helps me keep track of issues and give better support.
## https://discord.gg/xKgQZ6wZvS
### If you think I did a good job here, consider donating as it keeps by lights on and my cat fat/floofy: ### If you think I did a good job here, consider donating as it keeps by lights on and my cat fat/floofy:
https://ko-fi.com/jixelpatterns ## https://ko-fi.com/jixelpatterns
--- ---

View File

@@ -158,26 +158,16 @@ local function PlayATMAnimation(animation)
end end
end end
local function GrabAccount(type, job)
local p = promise.new()
QBCore.Functions.TriggerCallback('jim-payments:ManageWrapper', function(cb) p:resolve(cb) end, type, job)
return Citizen.Await(p)
end
RegisterNetEvent('jim-payments:Client:ATM:use', function(data) RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
--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 p = promise.new() local p = promise.new()
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p) QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p)
local society local gsociety local cancelled = false local cancelled = false
if Config.Manage then if not Config.Manage then
society = GrabAccount("GetAccount", PlayerJob.name)
Wait(200)
gsociety = GrabAccount("GetGangAccount", PlayerGang.name)
else
local p = promise.new() local p = promise.new()
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) society = Citizen.Await(p) QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p)
local p2 = promise.new() local p2 = promise.new()
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) gsociety = Citizen.Await(p2) QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.gsociety = Citizen.Await(p2)
end end
local atmbartime = 2500 local atmbartime = 2500
local setoptions = {} local setoptions = {}
@@ -186,8 +176,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, } setoptions = { { value = "withdraw", text = "Withdrawl" }, }
setview = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>Welcome back, "..info.name.."<br><br>- Citizen ID -<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash)..'<br><br>- Options -' setview = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>Welcome back, "..info.name.."<br><br>- Citizen ID -<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash)..'<br><br>- Options -'
setheader = "💵 ATM Banking 💵" setheader = "💵 ATM Banking 💵"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
for k, v in pairs(Config.ATMModels) do for k, v in pairs(Config.ATMModels) do
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed, true) local playerCoords = GetEntityCoords(playerPed, true)
@@ -211,8 +201,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br>💵Cash - $"..cv(info.cash).."<br><br>- Options -"
setheader = "🏦 Banking 🏦" setheader = "🏦 Banking 🏦"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -224,10 +214,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -238,9 +229,10 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setheader = "💰 Savings 💰" setheader = "💰 Savings 💰"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -249,11 +241,17 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "society" then elseif data.id == "society" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name..
"<br><br>- Society Account -<br>"..
PlayerJob.label..
"<br><br>- Balances -<br>🏢"..
PlayerJob.label.." - $"..cv(info.society)..
"<br>🏦Bank - $"..cv(info.bank)
setheader = "🏢 Society Banking 🏢" setheader = "🏢 Society Banking 🏢"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -262,11 +260,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "societytransfer" then elseif data.id == "societytransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(info.society).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -276,11 +274,12 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gang" then elseif data.id == "gang" then
setheader = "🏢 Society Banking 🏢" setheader = "🏢 Society Banking 🏢"
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.gsociety).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } } setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error") TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -289,12 +288,13 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gangtransfer" then elseif data.id == "gangtransfer" then
setoptions = { { value = "transfer", text = "Transfer" } } setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br><br>- Options -" setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(info.gsociety).."<br><br>- Options -"
setheader = "🔀 Transfer Services 🔀" setheader = "🔀 Transfer Services 🔀"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' }, { type = 'text', isRequired = true, name = 'account', text = '🏦 Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, } { type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
PlayATMAnimation('enter') PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function() end, function()
@@ -310,7 +310,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
if dialog then if dialog then
if not dialog.amount then return end if not dialog.amount then return end
PlayATMAnimation('exit') Citizen.Wait(1000) PlayATMAnimation('exit') Citizen.Wait(1000)
TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, society, gsociety) TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, info.society, info.gsociety)
end end
end end
end) end)
@@ -320,18 +320,18 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
local onlineList = {} local onlineList = {}
local nearbyList = {} local nearbyList = {}
QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end
for k, v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do for _, id in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId())) local dist = #(GetEntityCoords(GetPlayerPed(id)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) then if onlineList[i].value == GetPlayerServerId(id) then
if v ~= PlayerId() or Config.Debug then if id ~= PlayerId() or Config.Debug then
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' } nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
end end
end end
end end
dist = nil dist = nil
end end
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
local dialog = exports['qb-input']:ShowInput({ header = "Give someone cash", submitText = "Give", local dialog = exports['qb-input']:ShowInput({ header = "Give someone cash", submitText = "Give",
inputs = { inputs = {
{ text = " ", name = "citizen", type = "select", options = nearbyList }, { text = " ", name = "citizen", type = "select", options = nearbyList },

View File

@@ -11,14 +11,6 @@ local function cv(amount)
return formatted return formatted
end end
---- BANK STUFF
QBCore.Functions.CreateCallback('jim-payments:ManageWrapper', function(source, cb, type, account)
local result = nil
if type == "GetAccount" then result = exports["qb-management"]:GetAccount(account) end
if type == "GetGangAccount" then result = exports["qb-management"]:GetGangAccount(account) end
cb(result)
end)
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety) RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
local src = source local src = source
local Player = QBCore.Functions.GetPlayer(src) local Player = QBCore.Functions.GetPlayer(src)
@@ -105,11 +97,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
if (society - amount) >= 0 then if (society - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%' local query = '%"account":"' .. baccount .. '"%'
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] ~= nil then if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount) if Config.Manage then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.job.name), amount) end
if Reciever ~= nil then if Reciever then
Reciever.Functions.AddMoney('bank', amount) Reciever.Functions.AddMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success") TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.job.label).." account", "success")
@@ -118,7 +110,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid}) MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end end
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
@@ -157,11 +149,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
if (gsociety - amount) >= 0 then if (gsociety - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%' local query = '%"account":"' .. baccount .. '"%'
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] ~= nil then if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) if Config.Manage then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end else TriggerEvent("qb-bossmenu:server:removeAccountMoney", tostring(Player.PlayerData.gang.name), amount) end
if Reciever ~= nil then if not Reciever then
Reciever.Functions.AddMoney('bank', amount) Reciever.Functions.AddMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success") TriggerClientEvent("QBCore:Notify", src, "Sent $"..amount.." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..tostring(Player.PlayerData.gang.label).." account", "success")
@@ -170,7 +162,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid}) MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end end
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
@@ -191,10 +183,10 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
if (Player.PlayerData.money.bank - amount) >= 0 then if (Player.PlayerData.money.bank - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%' local query = '%"account":"' .. baccount .. '"%'
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] ~= nil then if result[1] then
local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid)
Player.Functions.RemoveMoney('bank', amount) Player.Functions.RemoveMoney('bank', amount)
if Reciever ~= nil then if Reciever then
Reciever.Functions.AddMoney('bank', amount) Reciever.Functions.AddMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "Sent $"..cv(amount).." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success") TriggerClientEvent("QBCore:Notify", src, "Sent $"..cv(amount).." to "..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success")
TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success") TriggerClientEvent("QBCore:Notify", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success")
@@ -203,7 +195,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount) RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid}) MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
end end
elseif result[1] == nil then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error") elseif not result[1] then TriggerClientEvent("QBCore:Notify", src, "Error: Account '"..baccount.."' not found", "error")
end end
end end
@@ -217,26 +209,43 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
local cash = Player.Functions.GetMoney("cash") local cash = Player.Functions.GetMoney("cash")
local bank = Player.Functions.GetMoney("bank") local bank = Player.Functions.GetMoney("bank")
local account = Player.PlayerData.charinfo.account local account = Player.PlayerData.charinfo.account
local society = 0
local gsociety = 0
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' }) -- If qb-management, grab info directly from database
if getSavingsAccount[1] ~= nil then if Config.Manage then
aid = getSavingsAccount[1].record_id local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
savbal = getSavingsAccount[1].amount for k, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end
end
if Player.PlayerData.gang.name ~= "none" then
for k, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end
end
else
end
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
if result[1] then
accountID = result[1].record_id
savingBalance = result[1].amount
else else
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, amount, account_type) VALUES (?, ?, ?)', { Player.PlayerData.citizenid, 0, 'Savings' }, function() completed = true end) repeat Wait(0) until completed == true MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, amount, account_type) VALUES (?, ?, ?)', { Player.PlayerData.citizenid, 0, 'Savings' }, function() completed = true end) repeat Wait(0) until completed == true
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' }) local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
aid = getSavingsAccount[1].record_id aid = result[1].record_id
savbal = getSavingsAccount[1].amount savingBalance = result[1].amount
end end
local data = { cb({name = name,
name = name,
cash = cash, cash = cash,
bank = bank, bank = bank,
account = account, account = account,
cid = cid, cid = cid,
savbal = savbal, savbal = savingBalance,
aid = aid } aid = accountID,
cb(data) society = society,
gsociety = gsociety})
end) end)
QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end) QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)

View File

@@ -84,7 +84,7 @@ RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[#nearbyList] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList } newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = '# Customer ID #' } newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = '# Customer ID #' }
@@ -129,7 +129,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[#nearbyList] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end if not nearbyList[1] then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList } newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList }
else -- If Config.List is false, create input text box for ID's else -- If Config.List is false, create input text box for ID's
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = "# Person's ID #" } newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = "# Person's ID #" }

View File

@@ -219,7 +219,7 @@ end)
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb) QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
local onlineList = {} local onlineList = {}
for k, v in pairs(QBCore.Functions.GetPlayers()) do for _, v in pairs(QBCore.Functions.GetPlayers()) do
local P = QBCore.Functions.GetPlayer(v) local P = QBCore.Functions.GetPlayer(v)
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname } onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
end end