[SOLVED] Teleporting not working

Hey guys, I hope someone can help me. I am trying to add teleporting to the Scorpion Trainer.

The following should teleport to the waypoint but it doesn’t teleport to the right coords.

RegisterNUICallback("teleport", function(data, cb)
	local playerPed = GetPlayerPed(-1)
	local action = data.action
	local VehicleHandle = GetClosestVehicle(GetEntityCoords(playerPed, true), 999999.0, 0, 71)
	local WaypointHandle = GetFirstBlipInfoId(8)
	local WaypointPos = GetBlipCoords(WaypointHandle)
	local playerVeh = GetVehiclePedIsIn(playerPed, 0)
	local newPos = GetEntityCoords(playerPed, false)
	
	if action == "nearestcar" then
		SetPedIntoVehicle(playerPed, VehicleHandle, -1)
		drawNotification("~g~Teleported Into Nearest Car.")
	elseif action == "waypoint" then
		if DoesBlipExist(WaypointHandle) then
			if IsPedInAnyVehicle(playerPed, 0) then
				SetEntityCoordsNoOffset(playerVeh, WaypointPos, 0, 0, 0)
			else
				SetEntityCoordsNoOffset(playerPed, WaypointPos, 0, 0, 0)
			end
			drawNotification("New location: " .. newPos.x .. ", " .. newPos.y .. ", " .. newPos.z)
			drawNotification("~g~Teleported To Waypoint!")
		else
			drawNotification("~r~No Waypoint Set!")
		end
	end
	cb("ok")
end)

Somehow GetBlipCoords outputs a 10 - digit number instead of coordinates :thinking:

I hope someone can help me

1 Like

Hey, not sure if you figured this out, but I just ran into the same issue.

I was able to fix it by doing this:local coord = Citizen.InvokeNative(0xFA7C7F0AADF25D09, blip, Citizen.ResultAsVector())
The blip variable would be the blip ID you want to get the coordinate of.

2 Likes

Thank you very much. If you were here, I would kiss you :grin:

Searching for over a month…

Lol. Glad I could help. I know how frustrating silly things like that can be.

2 Likes

The Z is always 1 for me though, how to get the actual Z so we don’t fall through ground or air ?

Thanks