[Release] Player coords saver to .Txt

hi, can you add position H plz ?

Better like this, for copy/paste coords for other mods :

file:write("[x = " .. x .. ", y = " .. y .. ", z = " .. z .. "]\n")

Hello, good job !
I adjust the elevation

Here is the script server side

print("Write /pos ingame to save the coords in a .txt in server's main folder")

RegisterServerEvent("SaveCoords")
AddEventHandler("SaveCoords", function(PlayerName , x , y , z)


function ajustHauteur(hauteur)
calcul = hauteur - 0.9
return calcul
end


file = io.open( PlayerName .. "-Coords.txt", "a")
if file then
file:write("{"..x..","..y..","..ajustHauteur(z).."},")
file:write("\n")
end
file:close()
end)

AddEventHandler("chatMessage", function(p, color, msg)
if msg:sub(1, 1) == "/" then
fullcmd = stringSplit(msg, " ")
cmd = fullcmd[1]

if cmd == "/pos" then
TriggerClientEvent("SaveCommand", p)
CancelEvent()
end
end
end)

function stringSplit(self, delimiter)
local a = self:Split(delimiter)
local t = {}

for i = 0, #a - 1 do
table.insert(t, a[i])
end

return t
end

In this resource there is one error if you have groups, im superadmin in my server and when i type /pos the game say i dont have permissions… :S

don’t know if this is still relevant but i had the same problem with “insufficient permissions”, change your rank from “superadmin” to “owner” and it should work :slight_smile:

Thanks for the script !

I updated the script for FX-Server (String splitting has changed) and added a comment fonction.

Use : /pos + comment

Server side :


print("Write /pos ingame to save the coords in a .txt in server's main folder")

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

AddEventHandler("chatMessage", function(p, color, msg)
    if msg:sub(1, 1) == "/" then
        fullcmd = stringSplit(msg, " ")
        cmd = fullcmd[1]
        comment = fullcmd[2]
        if #fullcmd > 2 then
          for i=3, #fullcmd do
              comment = comment .. " " .. fullcmd[i]
          end
        end
        if cmd == "/pos" then
        	TriggerClientEvent("SaveCommand", p, comment)
        	CancelEvent()
        end
    end
end)

function stringSplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

Client side :

RegisterNetEvent("SaveCommand")
AddEventHandler("SaveCommand", function(comment)
		x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	    local PlayerName = GetPlayerName()
	    TriggerServerEvent("SaveCoords", PlayerName , x , y , z, comment)			
end)
7 Likes

is there any scripte to show coordinates like this online

X= 2669.716, Y= 3517.079, Z= 51.981, A= 0

this doesn’t work, please delete

It does work, use the fix for FXServer provided by @kult_klm
like two posts above yours.

too awesome thanks for this man life saver

This actually works bro…lol

After you edit the script files in server.lua and client.lua, go in-game and type (providing you have admin permissions)
eg: /pos ‘nameOfThePositionSoThatYouKnowWhatTheCo-ordsAre’ (No quotations :slight_smile: )
eg: /pos myrpserver
eg: /pos trainstation1
eg: /pos nightclub
eg: /pos mafiasyndicatedlocation

Much Love. lol @kult_klm, @Suppeer

When I use the fixed code I get this error I Have tried everything I can think of. any help?

stack traceback:
server/main.lua:212: in local ‘ref’
citizen:/scripting/lua/scheduler.lua:317: in function citizen:/scripting/lua/scheduler.lua:308

Yeah that does that to me aswell…but if you /pos first it should create a file then you /pos name of position etc eg:

{-211.70104980469,-1325.2578125,30.890405654907,benny’s},
{1854.3115234375,3687.5637207031,34.267086029053,newpolice blip},
{1848.7601318359,3690.0900878906,34.267086029053,boss},
{1827.4432373047,3693.4611816406,34.224220275879,vehspawn},
{1850.03125,3686.8618164063,34.267078399658,armories},
{1869.7113037109,3644.5288085938,33.93119430542,helotest},
{1819.9276123047,3695.6467285156,33.931816101074,vehdel},
{1850.7138671875,3683.4638671875,34.267078399658,copclock},
{1836.1058349609,3698.44921875,34.224292755127,vehsppointcop},
{1849.8544921875,3633.8969726563,33.877620697021,helosppoint},
{-448.08819580078,6008.3833007813,31.716396331787,bosspaleto},
{-445.28366088867,6009.9658203125,31.716396331787,armoriespaleto},
{-442.662109375,6012.2197265625,31.716396331787,cloakpaleto},
{-476.19458007813,5987.6186523438,31.336708068848,paletohelospawner},
{-470.13577270508,5980.5610351563,31.336708068848,paletohelospanwpoint},
{-479.86801147461,6028.529296875,31.340549468994,vehiclespawnerpaleto},
{-476.36361694336,6032.3237304688,31.340549468994,paletospoint},
{502.29919433594,-118.80087280273,60.980815887451,test1},
{1850.2381591797,3674.5773925781,33.78267288208,newvehdelsandy},
{-447.56207275391,6013.9140625,31.716396331787,paletoblip},
{-468.75619506836,6038.76953125,31.340547561646,paletodelete},
{-442.37426757813,6012.1796875,31.716398239136,cloakpaletonew},
{1841.5789794922,3695.2426757813,34.26770401001,newsscarspawn},

{1827.1003417969,3693.5388183594,34.224281311035,newsscarspoint},

So yeah.

/pos

then hit enter and it’ll create a file.

then:
/pos ‘nameofwhatever’ (without quotes)

I’ll post my updates when I get home but it basically saves heading also and confirmed working. It’s pretty minor so someone might be able to do it while I’m at work.

print("Write /pos ingame to save the coords in a .txt in server's main folder")

RegisterServerEvent("SaveCoords")
AddEventHandler("SaveCoords", function( PlayerName , x, y, z, h, comment )

 file = io.open( PlayerName .. "-Coords.txt", "a")
    if file then
        file:write("{ x = " .. x .. ", y = " .. y .. ", z = " .. z .. ", h = ".. h .. "}, {".. comment .."},")
        file:write("\n")
        print("Coords wrote to file")
    else
        print("Unable to find file")
    end
    file:close()
end)

AddEventHandler("chatMessage", function(p, color, msg)
    if msg:sub(1, 1) == "/" then
        fullcmd = stringSplit(msg, " ")
        cmd = fullcmd[1]
        comment = fullcmd[2]
        if #fullcmd > 2 then
          for i=3, #fullcmd do
              comment = comment .. " " .. fullcmd[i]
          end
        end
        if cmd == "/pos" then
            TriggerClientEvent("SaveCommand", p, comment)
            CancelEvent()
        end
    end
end)

function stringSplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end
RegisterNetEvent("SaveCommand")
AddEventHandler("SaveCommand", function(comment)
        x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
        h = GetEntityHeading(GetPlayerPed(-1))
        local PlayerName = GetPlayerName()
        TriggerServerEvent("SaveCoords", PlayerName , x, y, z, h, comment)            
end)

works well from previous edits and saves etc…but that damn es_admin2 throws up errors…no biggie but annoying…

[lslo-rp] KS: /pos test
Coords wrote to file
Error running system event handling function for resource es_admin2: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: server.lua:334: attempt to index a nil value (local ‘file’)
stack traceback:
server.lua:334: in function ‘appendNewPos’
server.lua:352: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:163: in function citizen:/scripting/lua/scheduler.lua:162
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:162: in function citizen:/scripting/lua/scheduler.lua:131
Sending heartbeat to live-internal.fivem.net:30110

[OLD STRUCTURE] {-442.37426757813,6012.1796875,31.716398239136,cloakpaletonew},

[NEW STRUCTURE] { x = 1813.0267333984, y = 3790.5815429688, z = 33.627681732178, h = 359.48355102539}, {test},

I modified/ fixed/ edited the original.

I changed the command from /pos to /savepos, to prevent conflicts with other resources.

Also it now saves to the resource folder, not the Server Folder, there is a Saved Folder, where it saves the .txt Files.

It saves like this:

{X: -1775.872, Y: -174.940, Z: 63.382} {H: 117.515} {Comment: Testing This Sh*t},

CoordsSaver [1.0.0].rar (1.7 KB)

VirusTotal Scan: Click Here

6 Likes

Awesome work bro. Works flawlessly with mello trainer server-side.

1 Like

Has nothing to do with mello trainer, this stand alone script as how i would call it can/does work perfectly on an clean FXServer with or without scripthook or anyhing

( ofcourse chat, for the command. thats default in )