diff --git a/README.md b/README.md
index a5f8954..96874fe 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,11 @@
- QBCore based payment system
- 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:
-https://ko-fi.com/jixelpatterns
+## https://ko-fi.com/jixelpatterns
---
@@ -171,4 +174,4 @@ FineJobList = true, -- "true" to use nearby player list feature in the cash regi
- `BankBlips` Enable this if you disabled qb-banking and need bank locations
- `ATMBlips` Enable this if you are a pyscho and need every ATM to be on the map too
- `Gabz` Enable to change to Gabz Bank locations, this corrects the ATM/Bank Cashier + Ticket Cash in
----
+---
\ No newline at end of file
diff --git a/atms.lua b/atms.lua
index d3a5f36..3a00b87 100644
--- a/atms.lua
+++ b/atms.lua
@@ -158,26 +158,16 @@ local function PlayATMAnimation(animation)
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)
--this grabs all the info from names to savings account numbers in the databases
local p = promise.new()
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
- if Config.Manage then
- society = GrabAccount("GetAccount", PlayerJob.name)
- Wait(200)
- gsociety = GrabAccount("GetGangAccount", PlayerGang.name)
- else
+ local cancelled = false
+ if not Config.Manage then
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()
- 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
local atmbartime = 2500
local setoptions = {}
@@ -186,8 +176,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "withdraw", text = "Withdrawl" }, }
setview = "

Welcome back, "..info.name.."
- Citizen ID -
"..info.cid.."
- Balances -
π¦Bank - $"..cv(info.bank).."
π΅Cash - $"..cv(info.cash)..'
- Options -'
setheader = "π΅ ATM Banking π΅"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
for k, v in pairs(Config.ATMModels) do
local playerPed = PlayerPedId()
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" } }
setview = "Welcome back, "..info.name.."
- Account -
"..info.account.."
"..info.cid.."
- Balances -
π¦Bank - $"..cv(info.bank).."
π΅Cash - $"..cv(info.cash).."
- Options -"
setheader = "π¦ Banking π¦"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Bank", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
@@ -224,10 +214,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
setoptions = { { value = "transfer", text = "Transfer" } }
setview = "Welcome back, "..info.name.."
- Account -
"..info.account.."
"..info.cid.."
- Balances -
π¦Bank - $"..cv(info.bank).."
- Options -"
setheader = "π Transfer Services π"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'text', isRequired = true, name = 'account', text = 'π¦ Account no.' },
- { type = 'number', isRequired = true, name = 'amount', text = 'πΈ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'text', isRequired = true, name = 'account', text = 'π¦ Account no.' },
+ { type = 'number', isRequired = true, name = 'amount', text = 'πΈ Amount to transfer' }, }
PlayATMAnimation('enter')
+
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
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" } }
setview = "Welcome back, "..info.name.."
- Account Info -
Savings ID: "..info.aid.."
"..info.cid.."
- Balances -
π°Savings - $"..cv(info.savbal).."
π¦Bank - $"..cv(info.bank).."
- Options -"
setheader = "π° Savings π°"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
PlayATMAnimation('enter')
+
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -249,11 +241,17 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "society" then
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
- setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerJob.label.."
- Balances -
π’"..PlayerJob.label.." - $"..cv(society).."
π¦Bank - $"..cv(info.bank).."
- Options -"
+ setview = "Welcome back, "..info.name..
+ "
- Society Account -
"..
+ PlayerJob.label..
+ "
- Balances -
π’"..
+ PlayerJob.label.." - $"..cv(info.society)..
+ "
π¦Bank - $"..cv(info.bank)
setheader = "π’ Society Banking π’"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
PlayATMAnimation('enter')
+
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -262,11 +260,11 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "societytransfer" then
setoptions = { { value = "transfer", text = "Transfer" } }
- setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerJob.label.."
- Balances -
π’"..PlayerJob.label.." - $"..cv(society).."
- Options -"
+ setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerJob.label.."
- Balances -
π’"..PlayerJob.label.." - $"..cv(info.society).."
- Options -"
setheader = "π Transfer Services π"
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'text', isRequired = true, name = 'account', text = 'π¦ Account no.' },
- { type = 'number', isRequired = true, name = 'amount', text = 'πΈ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'text', isRequired = true, name = 'account', text = 'π¦ Account no.' },
+ { type = 'number', isRequired = true, name = 'amount', text = 'πΈ Amount to transfer' }, }
PlayATMAnimation('enter')
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
@@ -276,11 +274,12 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gang" then
setheader = "π’ Society Banking π’"
- setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerGang.label.."
- Balances -
π’"..PlayerGang.label.." - $"..cv(gsociety).."
π¦Bank - $"..cv(info.bank).."
- Options -"
+ setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerGang.label.."
- Balances -
π’"..PlayerGang.label.." - $"..cv(info.gsociety).."
π¦Bank - $"..cv(info.bank).."
- Options -"
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
- setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
- { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
+ setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
+ { type = 'number', isRequired = true, name = 'amount', text = 'π΅ Amount to transfer' }, }
PlayATMAnimation('enter')
+
QBCore.Functions.Progressbar("accessing_atm", "Accessing Society Account", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
@@ -289,12 +288,13 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
elseif data.id == "gangtransfer" then
setoptions = { { value = "transfer", text = "Transfer" } }
- setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerGang.label.."
- Balances -
π’"..PlayerGang.label.." - $"..cv(gsociety).."
- Options -"
+ setview = "Welcome back, "..info.name.."
- Society Account -
"..PlayerGang.label.."
- Balances -
π’"..PlayerGang.label.." - $"..cv(info.gsociety).."
- Options -"
setheader = "π Transfer Services π"
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
{ type = 'text', isRequired = true, name = 'account', text = 'π¦ Account no.' },
{ type = 'number', isRequired = true, name = 'amount', text = 'πΈ Amount to transfer' }, }
PlayATMAnimation('enter')
+
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
end, function()
@@ -310,7 +310,7 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
if dialog then
if not dialog.amount then return end
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)
@@ -320,18 +320,18 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
local onlineList = {}
local nearbyList = {}
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
- local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
+ for _, id in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
+ local dist = #(GetEntityCoords(GetPlayerPed(id)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do
- if onlineList[i].value == GetPlayerServerId(v) then
- if v ~= PlayerId() or Config.Debug then
+ if onlineList[i].value == GetPlayerServerId(id) 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)' }
end
end
end
dist = nil
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",
inputs = {
{ text = " ", name = "citizen", type = "select", options = nearbyList },
diff --git a/atmserver.lua b/atmserver.lua
index 3d66f93..e504ccb 100644
--- a/atmserver.lua
+++ b/atmserver.lua
@@ -11,14 +11,6 @@ local function cv(amount)
return formatted
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)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
@@ -47,7 +39,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
elseif account == "savings" then
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
if getSavingsAccount[1] ~= nil then savbal = tonumber(getSavingsAccount[1].amount) aid = getSavingsAccount[1].record_id end
-
+
if billtype == "withdraw" then
if savbal >= amount then
savbal = savbal - amount
@@ -62,7 +54,7 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
elseif billtype == "deposit" then
if amount < bankB then
savbal = savbal + amount
- Player.Functions.RemoveMoney('bank', amount)
+ Player.Functions.RemoveMoney('bank', amount)
TriggerClientEvent("QBCore:Notify", src, "$"..cv(amount).." Deposited from bank account into savings", "success")
MySQL.Async.execute('UPDATE bank_accounts SET amount = ? WHERE citizenid = ? AND record_id = ?', { savbal, Player.PlayerData.citizenid, getSavingsAccount[1].record_id }, function(success)
if success then return true else return false end
@@ -100,16 +92,16 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
baccount = newiban
amount = tonumber(newAmount)
-
+
local Player = QBCore.Functions.GetPlayer(src)
if (society - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%'
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)
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
- if Reciever ~= nil then
+ if Reciever then
Reciever.Functions.AddMoney('bank', amount)
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")
@@ -118,10 +110,10 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
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
-
+
--Simple transfers from gang society account to bank --
elseif account == "gang" then
if billtype == "withdraw" then
@@ -152,16 +144,16 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
baccount = newiban
amount = tonumber(newAmount)
-
+
local Player = QBCore.Functions.GetPlayer(src)
if (gsociety - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%'
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)
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
- if Reciever ~= nil then
+ if not Reciever then
Reciever.Functions.AddMoney('bank', amount)
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")
@@ -170,13 +162,13 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
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
-
+
elseif account == "transfer" then
-
+
local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount)
local newiban = tostring(baccount)
@@ -186,15 +178,15 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
baccount = newiban
amount = tonumber(newAmount)
-
+
local Player = QBCore.Functions.GetPlayer(src)
if (Player.PlayerData.money.bank - amount) >= 0 then
local query = '%"account":"' .. baccount .. '"%'
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)
Player.Functions.RemoveMoney('bank', amount)
- if Reciever ~= nil then
+ if Reciever then
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", Reciever.PlayerData.source, "Recieved $"..cv(amount).." from "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, "success")
@@ -203,11 +195,11 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
RecieverMoney.bank = (RecieverMoney.bank + amount)
MySQL.Async.execute('UPDATE players SET money = ? WHERE citizenid = ?', {json.encode(RecieverMoney), result[1].citizenid})
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
end)
QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
@@ -217,26 +209,43 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb)
local cash = Player.Functions.GetMoney("cash")
local bank = Player.Functions.GetMoney("bank")
local account = Player.PlayerData.charinfo.account
-
- local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
- if getSavingsAccount[1] ~= nil then
- aid = getSavingsAccount[1].record_id
- savbal = getSavingsAccount[1].amount
- else
+ local society = 0
+ local gsociety = 0
+
+ -- If qb-management, grab info directly from database
+ if Config.Manage then
+ local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
+ 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
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' })
- aid = getSavingsAccount[1].record_id
- savbal = getSavingsAccount[1].amount
+ local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?', { Player.PlayerData.citizenid, 'Savings' })
+ aid = result[1].record_id
+ savingBalance = result[1].amount
end
- local data = {
- name = name,
+ cb({name = name,
cash = cash,
bank = bank,
account = account,
cid = cid,
- savbal = savbal,
- aid = aid }
- cb(data)
+ savbal = savingBalance,
+ aid = accountID,
+ society = society,
+ gsociety = gsociety})
end)
QBCore.Commands.Add("cashgive", "Pay a user nearby", {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)
@@ -246,7 +255,7 @@ RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
local Reciever = QBCore.Functions.GetPlayer(tonumber(citizen))
local amount = tonumber(price)
local balance = Player.Functions.GetMoney("cash")
-
+
if amount and amount > 0 then
if balance >= amount then
Player.Functions.RemoveMoney('cash', amount)
diff --git a/client.lua b/client.lua
index eb9a2ad..82699a2 100644
--- a/client.lua
+++ b/client.lua
@@ -84,7 +84,7 @@ RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
end
end
--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 }
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 #' }
@@ -129,7 +129,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
end
end
--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 }
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 #" }
diff --git a/server.lua b/server.lua
index 2e77fd5..f802742 100644
--- a/server.lua
+++ b/server.lua
@@ -219,9 +219,9 @@ end)
QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb)
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)
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname }
end
cb(onlineList)
-end)
+end)
\ No newline at end of file