From ea6c31f1d963c94d21bf64f2c8dca6bfea769c62 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 24 Feb 2019 11:21:49 +0100 Subject: [PATCH] Fixed fast travel performance, see #113 --- client/job.lua | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/client/job.lua b/client/job.lua index 62b56f2b..7da6270a 100644 --- a/client/job.lua +++ b/client/job.lua @@ -178,24 +178,20 @@ function OpenMobileAmbulanceActionsMenu() end function FastTravel(coords, heading) - TeleportFadeEffect(PlayerPedId(), coords, heading) -end + local playerPed = PlayerPedId() -function TeleportFadeEffect(entity, coords, heading) - Citizen.CreateThread(function() - DoScreenFadeOut(800) + DoScreenFadeOut(800) - while not IsScreenFadedOut() do - Citizen.Wait(0) + while not IsScreenFadedOut() do + Citizen.Wait(500) + end + + ESX.Game.Teleport(playerPed, coords, function() + DoScreenFadeIn(800) + + if heading then + SetEntityHeading(playerPed, heading) end - - ESX.Game.Teleport(entity, coords, function() - DoScreenFadeIn(800) - - if heading then - SetEntityHeading(entity, heading) - end - end) end) end