Fixed exploit with negative values and decimals

All float values are now rounded to a number. There's also an check for if the input is less than or equal to 0
This commit is contained in:
ElPumpo
2018-04-08 22:33:51 +02:00
parent e096edda07
commit 10c3273394
+24 -4
View File
@@ -77,12 +77,28 @@ Citizen.CreateThread(function()
RegisterNUICallback('menu_submit', function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
local post = true
if menu.submit ~= nil then
if(type(data.value) == "number") then
data.value = math.floor(tonumber(data.value))
-- Is the submitted data a number?
if tonumber(data.value) ~= nil then
-- Round float values
data.value = round(tonumber(data.value))
-- Check for negative value
if tonumber(data.value) <= 0 then
post = false
end
end
-- Don't post if the value is negative or if it's 0
if post then
menu.submit(data, menu)
else
ESX.ShowNotification('That input is invalid!')
end
menu.submit(data, menu)
end
cb('OK')
@@ -141,4 +157,8 @@ Citizen.CreateThread(function()
end
end)
end)
end)
function round(x)
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
end