Hello there,
I was working on making a client script that would teleport a player/vehicle to a waypoint.
I have done some coding for a private mod menu for GTA V and implemented my code from there but was unable to get a result that is pleasing.
With the below code I end up below the map no matter what:
function ShowNotification( text )
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end
RegisterCommand('wp', function(source, args, rawCommand)
local blip = GetFirstBlipInfoId(8)
if not DoesBlipExist(blip) then
ShowNotification("No waypoint is set!")
return
end
local x, y, z = table.unpack(GetBlipCoords(blip))
local targetEntity = PlayerPedId()
if IsPedInAnyVehicle(targetEntity) then
targetEntity = GetVehiclePedIsIn(targetEntity, false)
end
Citizen.CreateThread(function()
for i = 0, 32, 1 do
if i ~= 0 then
for attempt = 1000, 0, -100 do
RequestCollisionAtCoord(x, y, attempt)
Citizen.Wait(0)
end
end
local groundFound, groundZ = GetGroundZFor_3dCoord(x, y, attempt, true)
if groundFound then
z = groundZ
break
end
end
SetEntityCoords(targetEntity, x, y, z + 2, false, false, false, true)
end)
end, false)
I have checked out the following topics without any result: