ifbankB<amountthenTriggerClientEvent("QBCore:Notify",src,"Bank Balance too low","error")
elseifbankB>=tonumber(amount)then
TriggerClientEvent("QBCore:Notify",src,"Withdrew $"..cv(amount).." from the bank","success")-- Don't really need this as phone gets notified when money is withdrawn
TriggerClientEvent("QBCore:Notify",src,"Deposited $"..cv(amount).." into the Bank","success")
end
end
-- Transfers from bank to savings account --
elseifaccount=="savings"then
localgetSavingsAccount=MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?',{Player.PlayerData.citizenid,'Savings'})
TriggerClientEvent("QBCore:Notify",src,"$"..cv(amount).." Withdrawn from savings into bank account","success")
MySQL.Async.execute('UPDATE bank_accounts SET amount = ? WHERE citizenid = ? AND record_id = ?',{savbal,Player.PlayerData.citizenid,getSavingsAccount[1].record_id},function(success)
ifsuccessthenreturntrueelsereturnfalseend
end)
elseifsavbal<amountthen
TriggerClientEvent("QBCore:Notify",src,"Savings Balance too low","error")
end
elseifbilltype=="deposit"then
ifamount<bankBthen
savbal=savbal+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)
ifsuccessthenreturntrueelsereturnfalseend
end)
elseTriggerClientEvent("QBCore:Notify",src,"Bank Balance too low","error")
end
end
--Simple transfers from society account to bank --
elseifaccount=="society"then
ifbilltype=="withdraw"then
iftonumber(society)<amountthenTriggerClientEvent("QBCore:Notify",src,"Society balance too low","error")
elseiftonumber(society)>=amountthen
TriggerClientEvent("QBCore:Notify",src,"Withdrew $"..cv(amount).." from the "..Player.PlayerData.job.label.." account","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",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",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")
localgetSavingsAccount=MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?',{Player.PlayerData.citizenid,'Savings'})
ifgetSavingsAccount[1]~=nilthen
aid=getSavingsAccount[1].record_id
savbal=getSavingsAccount[1].amount
else
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, amount, account_type) VALUES (?, ?, ?)',{Player.PlayerData.citizenid,0,'Savings'},function()completed=trueend)repeatWait(0)untilcompleted==true
localgetSavingsAccount=MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_type = ?',{Player.PlayerData.citizenid,'Savings'})