diff --git a/[core]/es_extended/common/modules/math.lua b/[core]/es_extended/common/modules/math.lua index acd3fdc9..de49d422 100644 --- a/[core]/es_extended/common/modules/math.lua +++ b/[core]/es_extended/common/modules/math.lua @@ -36,3 +36,15 @@ function ESX.Math.Random(minRange, maxRange) return math.random(minRange or 1, maxRange or 10) end +---@param origin vector +---@param target vector +---@return number +function ESX.Math.GetHeadingFromCoords(origin, target) + local dx = target.x - origin.x + local dy = target.y - origin.y + + local heading = math.deg(math.atan(dy, dx)) + 90 + + return (heading + 360) % 360 +end +