Last active
March 30, 2019 14:15
-
-
Save DemmyDemon/a0b5a0a8549062c6534f995a1bdab576 to your computer and use it in GitHub Desktop.
pTeleport2d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pTeleport2d(x,y,heading) | |
x = x + 0.0 | |
y = y + 0.0 | |
heading = heading or 0.0 | |
heading = heading + 0.0 | |
local camHeading = GetGameplayCamRelativeHeading() | |
local camPitch = GetGameplayCamRelativePitch() | |
DoScreenFadeOut(500) | |
while not IsScreenFadedOut() do | |
Citizen.Wait(5) | |
end | |
local testElevation = 1000.0 | |
local foundZ = 0.0 | |
local found = false | |
while not found and testElevation > -500 do | |
RequestCollisionAtCoord(x,y,testElevation) | |
Citizen.Wait(15) | |
found, foundZ = GetGroundZFor_3dCoord(x,y,1000.0,Citizen.ReturnResultAnyway()) | |
testElevation = testElevation - 30.0 | |
end | |
if found then | |
SetEntityCoords(PlayerPedId(),x,y,foundZ,false,false,false) | |
SetEntityHeading(PlayerPedId(),heading) | |
end | |
SetGameplayCamRelativeHeading(camHeading) | |
SetGameplayCamRelativePitch(camPitch) | |
DoScreenFadeIn(200) | |
return found | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment