From 6ad856558137e2e4ffff83174d0b1aa4301735b7 Mon Sep 17 00:00:00 2001 From: B0STRA <119994243+B0STRA@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:20:31 -0600 Subject: [PATCH] Fix heading returned values Before these changes it would continually go negative past 0 and over 360, returning incorrect headings. --- client/misc.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/client/misc.lua b/client/misc.lua index f83a9786..89407a62 100644 --- a/client/misc.lua +++ b/client/misc.lua @@ -36,17 +36,22 @@ end) local function CopyCoords(data) local coords = GetEntityCoords(cache.ped) local heading = GetEntityHeading(cache.ped) - local formats = { - vector2 = "%.2f, %.2f", - vector3 = "%.2f, %.2f, %.2f", - vector4 = "%.2f, %.2f, %.2f, %.2f", - heading = - "%.2f" - } + local formats = { vector2 = "%.2f, %.2f", vector3 = "%.2f, %.2f, %.2f", vector4 = "%.2f, %.2f, %.2f, %.2f", heading = + "%.2f" } local format = formats[data] - local values = { coords.x, coords.y, coords.z, heading } - lib.setClipboard(string.format(format, table.unpack(values, 1, #format))) + local clipboardText = "" + if data == "vector2" then + clipboardText = string.format(format, coords.x, coords.y) + elseif data == "vector3" then + clipboardText = string.format(format, coords.x, coords.y, coords.z) + elseif data == "vector4" then + clipboardText = string.format(format, coords.x, coords.y, coords.z, heading) + elseif data == "heading" then + clipboardText = string.format(format, heading) + end + + lib.setClipboard(clipboardText) end RegisterCommand("vector2", function()