From e0d3a9ea6970b9d924e2a8ccbbb8067c55997446 Mon Sep 17 00:00:00 2001 From: Mojito-Fivem Date: Wed, 13 Oct 2021 23:01:06 +0100 Subject: [PATCH] refactor(client/functions): Simplify vector check with ternary --- client/functions.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 36e96a0..31e1c2d 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -141,7 +141,7 @@ end function QBCore.Functions.GetClosestPed(coords, ignoreList) local ped = PlayerPedId() if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end @@ -164,7 +164,7 @@ end function QBCore.Functions.GetClosestPlayer(coords) local ped = PlayerPedId() if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end @@ -189,7 +189,7 @@ function QBCore.Functions.GetPlayersFromCoords(coords, distance) local players = QBCore.Functions.GetPlayers() local ped = PlayerPedId() if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end @@ -212,7 +212,7 @@ function QBCore.Functions.GetClosestVehicle(coords) local closestDistance = -1 local closestVehicle = -1 if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end @@ -234,7 +234,7 @@ function QBCore.Functions.GetClosestObject(coords) local closestDistance = -1 local closestObject = -1 if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end @@ -272,7 +272,7 @@ function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked) local model = GetHashKey(model) local ped = PlayerPedId() if coords then - if type(coords) == 'table' then coords = vector3(coords.x, coords.y, coords.z) end + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords else coords = GetEntityCoords(ped) end