mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +00:00
refactor(maths): move maths function to shared.lua
This commit is contained in:
+1
-21
@@ -1,5 +1,4 @@
|
||||
QBCore.Functions = {}
|
||||
QBCore.Functions.Math = {}
|
||||
QBCore.RequestId = 0
|
||||
|
||||
-- Player
|
||||
@@ -629,23 +628,4 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props)
|
||||
SetVehicleLivery(vehicle, props.modLivery)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Extra Math Functions
|
||||
|
||||
-- Math Rounding Credits: http://lua-users.org/wiki/SimpleRound
|
||||
function QBCore.Functions.Math.Sign(v)
|
||||
return (v >= 0 and 1) or -1
|
||||
end
|
||||
|
||||
-- Math Rounding Credits: http://lua-users.org/wiki/SimpleRound
|
||||
-- Usage:
|
||||
-- QBCore.Functions.Math.Round(119.68, 0.01) = 119.68
|
||||
-- QBCore.Functions.Math.Round(119.68, 0.1) = 119.7
|
||||
-- QBCore.Functions.Math.Round(119.68) = 120
|
||||
-- QBCore.Functions.Math.Round(119.68, 100) = 100
|
||||
-- QBCore.Functions.Math.Round(119.68, 1000) = 0
|
||||
function QBCore.Functions.Math.Round(v, bracket)
|
||||
bracket = bracket or 1
|
||||
return QBCore.Functions.Math.Sign(v/bracket + QBCore.Functions.Math.Sign(v) * 0.5) * bracket
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user