RegisterServerEvent("okokBanking:DepositMoney")
AddEventHandler("okokBanking:DepositMoney", function(amount)
local xPlayer = ESX.GetPlayerFromId(source)
local playerMoney = xPlayer.getMoney()
if amount <= playerMoney then
xPlayer.removeAccountMoney('money', amount)
xPlayer.addAccountMoney('bank', amount)
TriggerEvent('okokBanking:AddDepositTransaction', amount, source)
TriggerClientEvent('okokBanking:updateTransactions', source, xPlayer.getAccount('bank').money, xPlayer.getMoney())
TriggerClientEvent('okokNotify:Alert', source, "BANK", "You have deposited "..amount.."€", 5000, 'success')
else
TriggerClientEvent('okokNotify:Alert', source, "BANK", "You don't have that much money on you", 5000, 'error')
end
end)
RegisterServerEvent("okokBanking:WithdrawMoney")
AddEventHandler("okokBanking:WithdrawMoney", function(amount)
local xPlayer = ESX.GetPlayerFromId(source)
local playerMoney = xPlayer.getAccount('bank').money
if amount <= playerMoney then
xPlayer.removeAccountMoney('bank', amount)
xPlayer.addAccountMoney('cash', amount)
TriggerEvent('okokBanking:AddWithdrawTransaction', amount, source)
TriggerClientEvent('okokBanking:updateTransactions', source, xPlayer.getAccount('bank').money, xPlayer.getMoney())
TriggerClientEvent('okokNotify:Alert', source, "BANK", "You have withdrawn "..amount.."€", 5000, 'success')
else
TriggerClientEvent('okokNotify:Alert', source, "BANK", "You don't have that much money on the bank", 5000, 'error')
end
end)