Put this clientside, for each decimal you want, add a 0 to both the 100s below. You can also change the Citizen.Trace which is inside your F8 key to your chat message instead.

function tD(n)
    n = math.ceil(n * 100) / 100
    return n
end

RegisterNetEvent("SaveCommand")
AddEventHandler("SaveCommand", function()
	x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	local PlayerName = GetPlayerName()
	Citizen.Trace(""..tD(x)..","..tD(y)..","..tD(z)..","..tD(GetEntityHeading(GetPlayerPed(-1))).."")
	TriggerServerEvent( "SaveCoords", PlayerName , tD(x) , tD(y) , tD(z), tD(GetEntityHeading(GetPlayerPed(-1))) )			
end)

Put this serverside

RegisterServerEvent("SaveCoords")
AddEventHandler("SaveCoords", function( PlayerName , x , y , z, h )
    file = io.open( PlayerName .. "-Coords.txt", "a")
    if file then
        file:write("{" .. x .. "," .. y .. "," .. z .. "," .. h .. "}")
        file:write("\n")
    end
    file:close()
end)
1 Like