diff --git a/__resource.lua b/__resource.lua index 64f8f083..a143d696 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Atm' -version '1.0.0' +version '1.1.0' server_scripts { '@es_extended/locale.lua', @@ -31,11 +31,11 @@ client_scripts { ui_page 'html/ui.html' files { - 'html/ui.html', + 'html/ui.html', 'html/roboto.ttf', 'html/img/fleeca.png', - 'html/css/app.css', - 'html/scripts/app.js' + 'html/css/app.css', + 'html/scripts/app.js' } dependency 'es_extended' \ No newline at end of file diff --git a/client/main.lua b/client/main.lua index abf512a7..f5153f44 100644 --- a/client/main.lua +++ b/client/main.lua @@ -60,7 +60,7 @@ Citizen.CreateThread(function() SetBlipColour (blip, 2) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") - AddTextComponentString("ATM") + AddTextComponentString(_U('atm')) EndTextCommandSetBlipName(blip) end end) @@ -121,7 +121,7 @@ Citizen.CreateThread(function() ESX.TriggerServerCallback('esx:getPlayerData', function(data) SendNUIMessage({ showMenu = true, - player = { + player = { money = data.money, accounts = data.accounts } diff --git a/html/scripts/app.js b/html/scripts/app.js index 2adc9f82..f05256bb 100644 --- a/html/scripts/app.js +++ b/html/scripts/app.js @@ -1,50 +1,43 @@ $(window).ready(function () { - // NUI Callback - window.addEventListener('message', function (event) { - let data = event.data; - if (data.showControls) { - $('#container').show(); - $('#menu').hide(); - } - if (data.showMenu) { - $('#container').show(); - $('#menu').show(); - $('#deposit_amount').val(data.player.money); - let bankAmount = 0; - for (let i = 0; i < data.player.accounts.length; i++) - if (data.player.accounts[i].name == 'bank') - bankAmount = data.player.accounts[i].money; - if (bankAmount >= 10000) { - $('#withdraw_amount').val(10000); - } else { - $('#withdraw_amount').val(bankAmount); - } - } + // NUI Callback + window.addEventListener('message', function (event) { + let data = event.data; - if (data.hideAll) { - $('#container').hide(); - } - }); + if (data.showMenu) { + $('#container').fadeIn(); + $('#menu').fadeIn(); + $('#deposit_amount').val(data.player.money); + let bankAmount = 0; + for (let i = 0; i < data.player.accounts.length; i++) { + if (data.player.accounts[i].name == 'bank') { + bankAmount = data.player.accounts[i].money; + } + } + $('#withdraw_amount').val(bankAmount); + } else if (data.hideAll) { + $('#container').fadeOut(); + } + }); - document.onkeyup = function (data) { - if (data.which == 27) { - $.post('http://esx_atm/escape', '{}'); - } - }; + document.onkeyup = function (data) { + if (data.which == 27) { + $.post('http://esx_atm/escape', '{}'); + } + }; - $('#container').hide(); + $('#container').hide(); - $('#deposit_btn').on('click', function () { - $.post('http://esx_atm/deposit', JSON.stringify({ - amount: $('#deposit_amount').val() - })); - }) + $('#deposit_btn').on('click', function () { + $.post('http://esx_atm/deposit', JSON.stringify({ + amount: $('#deposit_amount').val() + })); + $('#deposit_amount').val(0); + }) - $('#withdraw_btn').on('click', function () { - $.post('http://esx_atm/withdraw', - JSON.stringify({ - amount: $('#withdraw_amount').val() - }) - ); - }); + $('#withdraw_btn').on('click', function () { + $.post('http://esx_atm/withdraw', JSON.stringify({ + amount: $('#withdraw_amount').val() + })); + $('#withdraw_amount').val(0); + }); }); diff --git a/html/ui.html b/html/ui.html index 15c4cb0c..fca7b0eb 100644 --- a/html/ui.html +++ b/html/ui.html @@ -23,12 +23,9 @@ - - - \ No newline at end of file diff --git a/html/ui_de.html b/html/ui_de.html index e14331b4..ae941d43 100644 --- a/html/ui_de.html +++ b/html/ui_de.html @@ -25,9 +25,7 @@ - - \ No newline at end of file diff --git a/html/ui_en.html b/html/ui_en.html index 9e0a7756..3b77bab8 100644 --- a/html/ui_en.html +++ b/html/ui_en.html @@ -10,7 +10,7 @@
Hi,
- Thank you for using our Fleece Bank terminals + Thank you for using our Fleece Bank terminals
+ - - \ No newline at end of file diff --git a/locales/br.lua b/locales/br.lua index 1414b193..7cb98fad 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -3,4 +3,5 @@ Locales['br'] = { ['deposit_money'] = 'Você depósitou ~g~$%s~s~', ['withdraw_money'] = 'Você retirou ~g~$%s~s~', ['press_e_atm'] = 'pressione ~INPUT_PICKUP~ para depósitos ou retiradas do ~g~ATM~s~.', + ['atm_blip'] = 'ATM', } diff --git a/locales/de.lua b/locales/de.lua index 784a4f88..370df7b8 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -3,4 +3,5 @@ Locales['de'] = { ['deposit_money'] = 'eingezahlt ~g~$%s~s~', ['withdraw_money'] = 'abgehoben ~g~$%s~s~', ['press_e_atm'] = 'Drücke ~INPUT_PICKUP~ um auf den ~g~ATM~s~ zuzugreifen.', + ['atm_blip'] = 'ATM', } diff --git a/locales/en.lua b/locales/en.lua index 12346b19..bc0bba20 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -3,4 +3,5 @@ Locales['en'] = { ['deposit_money'] = 'you have deposited ~g~$%s~s~', ['withdraw_money'] = 'you have withdrawn ~g~$%s~s~', ['press_e_atm'] = 'press ~INPUT_PICKUP~ for deposit or withdrawal from ~g~ATM~s~', + ['atm_blip'] = 'ATM', } diff --git a/locales/es.lua b/locales/es.lua index 43b4cc72..6448fe18 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -3,4 +3,5 @@ Locales['es'] = { ['deposit_money'] = 'has depositado ~g~€%s~s~', ['withdraw_money'] = 'has retirado ~g~€%s~s~', ['press_e_atm'] = 'presiona ~INPUT_PICKUP~ para depositar o retirar ~g~cash~s~.', + ['atm_blip'] = 'ATM', } diff --git a/locales/fr.lua b/locales/fr.lua index 4c8490e8..a1486017 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -3,4 +3,5 @@ Locales['fr'] = { ['deposit_money'] = 'vous avez déposé ~g~$%s~s~', ['withdraw_money'] = 'vous avez retiré ~g~$%s~s~', ['press_e_atm'] = 'appuyez sur ~INPUT_PICKUP~ pour déposer ou retirer du ~g~cash~s~.', + ['atm_blip'] = 'ATM', } \ No newline at end of file diff --git a/locales/sv.lua b/locales/sv.lua index fe965d34..67e8cc25 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -3,4 +3,5 @@ Locales['sv'] = { ['deposit_money'] = 'du satte in ~g~$%s~s~', ['withdraw_money'] = 'du har tagit ut ~g~$%s~s~', ['press_e_atm'] = 'tryck ~INPUT_PICKUP~ för att komma åt denna ~g~ATM~s~', + ['atm_blip'] = 'bankomat', } diff --git a/server/main.lua b/server/main.lua index 5a433e5a..a9e8448e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -6,22 +6,22 @@ AddEventHandler('esx_atm:deposit', function(amount) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) amount = tonumber(amount) + amount = round(amount) if amount == nil or amount <= 0 or amount > xPlayer.getMoney() then TriggerClientEvent('esx:showNotification', _source, _U('invalid_amount')) else xPlayer.removeMoney(amount) xPlayer.addAccountMoney('bank', amount) TriggerClientEvent('esx:showNotification', _source, _U('deposit_money', amount)) - TriggerClientEvent('esx_atm:closeATM', _source) end end) - RegisterServerEvent('esx_atm:withdraw') AddEventHandler('esx_atm:withdraw', function(amount) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) amount = tonumber(amount) + amount = round(amount) local accountMoney = 0 accountMoney = xPlayer.getAccount('bank').money if amount == nil or amount <= 0 or amount > accountMoney then @@ -30,6 +30,9 @@ AddEventHandler('esx_atm:withdraw', function(amount) xPlayer.removeAccountMoney('bank', amount) xPlayer.addMoney(amount) TriggerClientEvent('esx:showNotification', _source, _U('withdraw_money', amount)) - TriggerClientEvent('esx_atm:closeATM', _source) end -end) \ No newline at end of file +end) + +function round(x) + return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5) +end \ No newline at end of file