Fixed decimal exploit, cleanup

This commit is contained in:
ElPumpo
2018-06-09 18:25:50 +02:00
parent 296ce29534
commit f4291d1564
13 changed files with 57 additions and 62 deletions
+4 -4
View File
@@ -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'
+2 -2
View File
@@ -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
}
+36 -43
View File
@@ -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);
});
});
-3
View File
@@ -23,12 +23,9 @@
<button id="withdraw_btn">Retirer</button>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="scripts/app.js"></script>
</body>
</html>
-2
View File
@@ -25,9 +25,7 @@
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="scripts/app.js"></script>
</body>
</html>
+2 -4
View File
@@ -10,7 +10,7 @@
</div>
<div id="welcome-text">
Hi, <br/>
Thank you for using our Fleece Bank terminals
Thank you for using our Fleece Bank terminals
</div>
<div id="menu">
<div>
@@ -22,12 +22,10 @@
<input type="number" id="withdraw_amount"/>
<button id="withdraw_btn">Withdraw</button>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="scripts/app.js"></script>
</body>
</html>
+1
View File
@@ -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',
}
+1
View File
@@ -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',
}
+1
View File
@@ -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',
}
+1
View File
@@ -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',
}
+1
View File
@@ -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',
}
+1
View File
@@ -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',
}
+7 -4
View File
@@ -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)
end)
function round(x)
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
end