Exploit fixed: money negative values

This commit is contained in:
ElPumpo
2018-04-28 11:34:25 +02:00
parent 160dc9c849
commit 0edf413a99
2 changed files with 53 additions and 13 deletions
+43 -6
View File
@@ -14,7 +14,11 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
self.identifier = self.player.get('identifier')
self.setMoney = function(m)
self.player.setMoney(m)
if m >= 0 then
self.player.setMoney(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried setting -1 cash balance)')
end
end
self.getMoney = function()
@@ -22,7 +26,11 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.setBankBalance = function(m)
self.player.setBankBalance(m)
if m >= 0 then
self.player.setBankBalance(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried setting -1 bank balance)')
end
end
self.getBank = function()
@@ -42,19 +50,35 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.addMoney = function(m)
self.player.addMoney(m)
if m >= 0 then
self.player.addMoney(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried adding -1 cash balance)')
end
end
self.removeMoney = function(m)
self.player.removeMoney(m)
if m >= 0 then
self.player.removeMoney(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried removing -1 cash balance)')
end
end
self.addBank = function(m)
self.player.addBank(m)
if m >= 0 then
self.player.addBank(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried adding -1 bank balance)')
end
end
self.removeBank = function(m)
self.player.removeBank(m)
if m >= 0 then
self.player.removeBank(m)
else
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried removing -1 bank balance)')
end
end
self.displayMoney = function(m)
@@ -227,6 +251,10 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.setAccountMoney = function(a, m)
if m < 0 then
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried setting -1 account balance)')
return
end
local account = self.getAccount(a)
local prevMoney = account.money
@@ -242,6 +270,10 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.addAccountMoney = function(a, m)
if m < 0 then
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried adding -1 account balance)')
return
end
local account = self.getAccount(a)
local newMoney = account.money + m
@@ -256,6 +288,11 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.removeAccountMoney = function(a, m)
if m < 0 then
print('es_extended: ' .. self.name .. ' (' .. self.identifier .. ') attempted exploiting! (reason: player tried removing -1 account balance)')
return
end
local account = self.getAccount(a)
local newMoney = account.money - m
+10 -7
View File
@@ -79,15 +79,15 @@ TriggerEvent('es:addGroupCommand', 'setmoney', 'admin', function(source, args, u
local money_type = args[2]
local money_amount = tonumber(args[3])
local xTarget = ESX.GetPlayerFromId(target)
local xPlayer = ESX.GetPlayerFromId(target)
if target and money_type and money_amount and xTarget ~= nil then
if target and money_type and money_amount and xPlayer ~= nil then
if money_type == 'cash' then
xTarget.setMoney(money_amount)
xPlayer.setMoney(money_amount)
elseif money_type == 'bank' then
xTarget.setAccountMoney('bank', money_amount)
xPlayer.setAccountMoney('bank', money_amount)
elseif money_type == 'black' then
xTarget.setAccountMoney('black_money', money_amount)
xPlayer.setAccountMoney('black_money', money_amount)
else
TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, "^2" .. money_type .. " ^0 is not a valid money type!")
return
@@ -97,8 +97,11 @@ TriggerEvent('es:addGroupCommand', 'setmoney', 'admin', function(source, args, u
return
end
print('es_extended: ' .. GetPlayerName(source) .. ' just set $' .. money_amount .. ' (' .. money_type .. ') to ' .. xTarget.name)
TriggerClientEvent('esx:showNotification', xTarget.source, _U('money_set', money_amount, money_type))
print('es_extended: ' .. GetPlayerName(source) .. ' just set $' .. money_amount .. ' (' .. money_type .. ') to ' .. xPlayer.name)
if xPlayer.source ~= _source then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('money_set', money_amount, money_type))
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
end, {help = _U('setmoney'), params = {{name = "id", help = _U('id_param')}, {name = "money type", help = _U('money_type')}, {name = "amount", help = _U('money_amount')}}})