diff --git a/client/functions.lua b/client/functions.lua index ba0d1791..bf309bfd 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -308,21 +308,16 @@ ESX.Game.GetPedMugshot = function(ped, transparent) end ESX.Game.Teleport = function(entity, coords, cb) + local vector = type(coords) == "vector4" and coords or type(coords) == "vector3" and vector4(coords, 0.0) or vec(coords.x, coords.y, coords.z, coords.heading or 0.0) + if DoesEntityExist(entity) then - RequestCollisionAtCoord(coords.x, coords.y, coords.z) - local timeout = 0 - - -- we can get stuck here if any of the axies are "invalid" - while not HasCollisionLoadedAroundEntity(entity) and timeout < 2000 do - Citizen.Wait(0) - timeout = timeout + 1 + RequestCollisionAtCoord(vector.xyz) + while not HasCollisionLoadedAroundEntity(entity) do + Wait(0) end - SetEntityCoords(entity, coords.x, coords.y, coords.z, false, false, false, false) - - if type(coords) == 'table' and coords.heading then - SetEntityHeading(entity, coords.heading) - end + SetEntityCoords(entity, vector.xyz, false, false, false, false) + SetEntityHeading(entity, vector.w) end if cb then