fix(client/functions): Additional type checking for vectors

This commit is contained in:
Mojito-Fivem
2021-10-07 22:16:03 +01:00
parent b1ca2926a1
commit ca30d45810
+11 -2
View File
@@ -233,7 +233,11 @@ function QBCore.Functions.GetClosestObject(coords)
local objects = GetGamePool('CObject')
local closestDistance = -1
local closestObject = -1
local coords = coords or GetEntityCoords(ped)
if coords then
if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end
else
coords = GetEntityCoords(ped)
end
for i = 1, #objects, 1 do
local objectCoords = GetEntityCoords(objects[i])
local distance = #(objectCoords - coords)
@@ -266,7 +270,12 @@ end
function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked)
local model = GetHashKey(model)
local coords = coords or QBCore.Functions.GetCoords(PlayerPedId())
local ped = PlayerPedId()
if coords then
if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end
else
coords = GetEntityCoords(ped)
end
local isnetworked = isnetworked or true
if not IsModelInCdimage(model) then return end
RequestModel(model)