fix: force vector3 on Teleport function

This commit is contained in:
MiddleSkillz
2021-05-06 02:34:03 -06:00
parent 0cc99faa5f
commit c9aaab9a08
+7 -12
View File
@@ -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