How to get coords from the serverid

Hi guys, i’m blocked on something.

I created a menu to get the server id of all players, and when i click on a player i can teleport to him.

But for a reason a i don’t know i can’t get his coords with his server id.
It return me vector3(0, 0, 0)

Someone know how i can get the coords of the player from the server id ?

Thank you for your help

Well, post the code that you’re trying to use, it’s always easier this way.

Well here is my code that i’m using.

RageUI.IsVisible(subMenuListesJoueurs, function()

            for k,v in pairs(listejoueur) do
                RageUI.Button(v[1], description, {RightLabel = "ID : "..v[2]}, true, {onSelected = function()
                    nameUser = v[1]
                    idUser = v[2]
                end}, subMenuListeCommandes);
            end

        end, function() end)

        RageUI.IsVisible(subMenuListeCommandes, function()

            RageUI.Button("Teleporter au joueur", "Se téléporter au joueur", {}, true, {onSelected = function()
                local playerPed = GetPlayerPed(-1)
                local targetPed = GetPlayerPed(idUser)

                NetworkSetInSpectatorMode(false, playerPed) -- turn off spectator mode just in case
                if PlayerId() == idUser then
                    sendNotification("~r~This player is you !")
                elseif not NetworkIsPlayerActive(idUser) then
                    sendNotification("~r~This player is not in game.")
                else
                  local targetCoords = GetEntityCoords(targetPed)
                  local targetVeh = GetVehiclePedIsIn(targetPed, False)
                  local seat = -1

                  sendNotification("~g~Teleporting to " .. nameUser .. " (Player id " .. idUser .. ").")

                    if targetVeh then
                        local numSeats = GetVehicleModelNumberOfSeats(GetEntityModel(targetVeh))
                        if numSeats > 1 then
                            for i=0, numSeats do
                                if seat == -1 and IsVehicleSeatFree(targetveh, i) then
                                    seat = 1
                                end
                            end
                        end
                    end
                    if seat == -1 then
                        SetEntityCoords(playerPed, targetCoords, 1, 0, 0, 1)
                    else
                        SetPedIntoVehicle(playerPed, targetVeh, seat)
                    end
                end
            end});
        end, function() end)

I don’t understand why this is not working :confused:

I found the solution.

Sending a TriggerServentEvent with the idUser, and use GetPlayerPed(id), and took coords with it.
Send a clientevent that teleport !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.