Get position does not work

Hi,

I’m using :

local pos = GetEntityCoords(GetPlayerPed(-1))
local string = "{ [‘x’] = " … pos.x … ", [‘y’] = " … pos.y … “, [‘z’] = " … pos.z … " },\n”
TriggerEvent(‘chatMessage’, ‘SYSTEME’, {255, 0, 0}, string)

Bu it does not work… Where is my mistake ?

Thank you,

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 )
file = io.open( PlayerName … “-Coords.txt”, “a”)
if file then
file:write("{" … x … “,” … y … “,” … 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

1 Like

Thank you so much guy !

No problem :slight_smile:

that server.lua or client.lua