schwim
4
Hi there, Scammer and thanks for the help!
I tried implementing this but have done something incorrectly, I think. Here’s my attempt:
RegisterNetEvent("SaveCommand")
function roundToNthDecimal(num, n)
local mult = 10^(n or 0)
return math.floor(num * mult + 0.5) / mult
end
AddEventHandler("SaveCommand", function()
x, y, z = table.unpack(roundToNthDecimal(GetEntityCoords(GetPlayerPed(-1), true)))
heading = GetEntityHeading(GetPlayerPed(-1))
local PlayerName = GetPlayerName()
TriggerServerEvent("SaveCoords", PlayerName , x , y , z, heading)
TriggerEvent("chatMessage", "SYSTEM", {255, 0, 0}, "Your coords are X:" .. x .. ", Y:" .. y .. ", Z:" .. z.." H:"..heading)
end)
But this is saving coords with a single zero as the decimal space, no matter where I stand.
I tried passing an argument for n as well, which caused the script to revert to full coords:
x, y, z = table.unpack(roundToNthDecimal(GetEntityCoords(GetPlayerPed(-1), true), 2))
Did I implement it incorrectly or is there perhaps a change I should have made to the code to get what I want?