diff --git a/resources/bank/bank.lua b/resources/bank/bank.lua index 503a3d5..e6a83d7 100644 --- a/resources/bank/bank.lua +++ b/resources/bank/bank.lua @@ -61,7 +61,7 @@ local function loadBank( id, x, y, z, rotation, interior, dimension, skin ) setElementInterior( bank, interior ) setElementDimension( bank, dimension ) - banks[ id ] = { bank = bank, canDeposit = skin ~= -1 } + banks[ id ] = { bank = bank, canDeposit = skin ~= -1, withdrawFee = skin == -1 and 2 or 0 } banks[ bank ] = id end @@ -408,7 +408,7 @@ addEventHandler( "bank:select", root, if balance then p[ source ].enteredPin = true p[ source ].ignoreUpdate = true - triggerClientEvent( source, "bank:single", bank.bank, balance, bank.canDeposit ) + triggerClientEvent( source, "bank:single", bank.bank, balance, bank.canDeposit, bank.withdrawFee ) else outputChatBox( "This service is currently not available.", source, 255, 0, 0 ) end @@ -522,10 +522,12 @@ addEventHandler( "bank:updateaccount", root, -- ignore if the amount is too large to be withdrawn if -amount > getAccountBalance( card[2] ) then return + elseif -amount + bank.withdrawFee > getAccountBalance( card[2] ) then + return end end - if modifyAccountBalance( card[2] , amount ) then + if modifyAccountBalance( card[2] , amount - ( amount < 0 and bank.withdrawFee or 0 ) ) then if amount < 0 then exports.players:giveMoney( source, -amount ) end diff --git a/resources/bank/bank_c.lua b/resources/bank/bank_c.lua index 20a836a..2a5e000 100644 --- a/resources/bank/bank_c.lua +++ b/resources/bank/bank_c.lua @@ -38,9 +38,9 @@ addEventHandler( "bank:promptPIN", resourceRoot, addEvent( "bank:single", true ) addEventHandler( "bank:single", resourceRoot, - function( balance, canDeposit ) + function( balance, canDeposit, withdrawFee ) exports.gui:hide( ) - exports.gui:updateBankSingle( balance, canDeposit ) + exports.gui:updateBankSingle( balance, canDeposit, withdrawFee ) exports.gui:show( 'bank_single', true ) end ) diff --git a/resources/gui/windows/bank.lua b/resources/gui/windows/bank.lua index 26b9efc..06d64b2 100644 --- a/resources/gui/windows/bank.lua +++ b/resources/gui/windows/bank.lua @@ -153,6 +153,7 @@ windows.bank_prompt_pin = -- local _balance = 0 +local _withdrawFee = 0 local function deposit( key ) if key ~= 2 and destroy and destroy['g:bank:amount'] then @@ -180,18 +181,21 @@ local function withdraw( key ) if amount <= 0 then outputChatBox( "Please enter an amount greater than 0.", 255, 0, 0 ) elseif amount > _balance then - outputChatBox( "You do not have so much money on your account.", 255, 0, 0 ) + outputChatBox( "You do not enough money on your account.", 255, 0, 0 ) + elseif amount + _withdrawFee > _balance then + outputChatBox( "You do not enough money on your account to pay the fee as well.", 255, 0, 0 ) else triggerServerEvent( "bank:updateaccount", getLocalPlayer( ), -amount ) - _balance = _balance - amount + _balance = _balance - amount - _withdrawFee windows.bank_single[2].text = "Your account balance: $" .. _balance .. "." end end end end -function updateBankSingle( balance, canDeposit ) +function updateBankSingle( balance, canDeposit, withdrawFee ) _balance = balance + _withdrawFee = withdrawFee or 0 windows.bank_single = { onClose = function( ) @@ -216,7 +220,7 @@ function updateBankSingle( balance, canDeposit ) }, { type = "button", - text = "Withdraw", + text = "Withdraw" .. ( _withdrawFee > 0 and ( " (Fee: $" .. withdrawFee .. ")" ) or "" ), onClick = withdraw, } }