Fixed round function not properly working in some locales, closes #258

This commit is contained in:
ElPumpo
2020-01-02 14:31:46 +01:00
parent 4187675148
commit 8eb1acd082
+2 -1
View File
@@ -1,7 +1,8 @@
ESX.Math = {}
ESX.Math.Round = function(value, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", value))
local mult = 10^(numDecimalPlaces or 0)
return math.floor(value * mult + 0.5) / mult
end
-- credit http://richard.warburton.it