Added ESX.Math.*

This commit is contained in:
ElPumpo
2018-10-22 22:37:20 +02:00
parent 99bf793b96
commit 4c5d1532b2
13 changed files with 158 additions and 131 deletions
+2 -3
View File
@@ -59,7 +59,6 @@ ESX.DumpTable = function(table, nb)
end
ESX.Round = function(value)
return value >= 0 and math.floor(value + 0.5) or math.ceil(value - 0.5)
ESX.Round = function(value, numDecimalPlaces)
return ESX.Math.Round(value, numDecimalPlaces)
end
+12
View File
@@ -0,0 +1,12 @@
ESX.Math = {}
ESX.Math.Round = function(value, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", value))
end
-- credit http://richard.warburton.it
ESX.Math.GroupDigits = function(value)
local left,num,right = string.match(value,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1' .. _U('locale_digit_grouping_symbol')):reverse())..right
end