Hi, i want to know coordinate of a player but server-side.
server.lua
RegisterNetEvent("mine_test")
AddEventHandler("mine_test", function()
print(GetEntityCoords(GetPlayerPed(source)).x)
print(GetPlayerName(source))
end)
And i trigger that event with a command. GetPlayerName works well. EntitityCoords print 0.0 even if I’m not at that coord.
I only want to save to database the last coordinates before quit.
1 Like
Getting the entity coords serversided works only on onesync
Oh i did not know that. Where you read this? @TheIndra
I have onesync but it still gives me wrong coordinates
player = ""
function getPlayerCoords(data)
local ped = GetPlayerPed(data)
local name = GetPlayerName(data)
local coords = GetEntityCoords(ped, true)
player = coords.x .. ";" .. coords.y .. ";" .. coords.x .. "#" .. name
end
RegisterServerCallback('getPlayer:get', function(source, data)
if (pcall(getPlayerCoords, data)) then
return player
else
return "error"
end
end)
(I have onesync infinity)