Getting coordinates always is 0,0,0

When I try to get my current coordinates, it always equates to 0, 0, 0?

RegisterCommand('911', function(source, args)
    local player = source
	local ped = GetPlayerPed(player)
	local playerCoords = GetEntityCoords(ped, false)
    -- TriggerEvent('callBlip', playerCoords)
    print(playerCoords)
end)

Assuming you’re on client, source is the players server id so you would need to use GetPlayerServerId and make sure to check it doesn’t return -1

If you’re on the client then this is valid (the server has no concept of a “local player” like the client does, hence anything marked as player/playerSrc would just be their source.) , and you should check to make sure you have one sync on

1 Like

If you’re on client, use this:

local ped = PlayerPedId()

(no need for source)

If you’re on server, code should be fine. If it doesn’t work, you could try to move the Register Command to a Client script, then triggering a Server Event with the exact same code. Of course, rather than TriggerEvent ‘callBlip’ you should use:

TriggerClientEvent('callBlip', player, playerCoords)

Remember that, when calling TriggerClientEvent, first parameter must be always the target client, so it’s either source (or player, in your case), or -1 for all clients

1 Like

Thanks a lot!

1 Like