Fixed mistakes with fuctions returning lists of players

Fixed some ESX functions that are used to get the closests, I forgot that the functions should've returned the player and not the entity handle :/

Also fixed the ESX.Game.GetClosestPed() function just returning your own ped.

Thanks @SSNRSS for helping me iron out the problems!

Co-Authored-By: Lucas. <ssnrss@users.noreply.github.com>
This commit is contained in:
ElPumpo
2020-04-15 20:08:00 +02:00
parent bd76482cae
commit 17ac9d5846
2 changed files with 30 additions and 24 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ local function EnumerateEntities(initFunc, moveFunc, disposeFunc)
end)
end
function EnumerateEntitiesWithinDistance(entities, coords, maxDistance)
function EnumerateEntitiesWithinDistance(entities, isPlayerEntities, coords, maxDistance)
local nearbyEntities = {}
if coords then
@@ -67,11 +67,11 @@ function EnumerateEntitiesWithinDistance(entities, coords, maxDistance)
coords = GetEntityCoords(playerPed)
end
for k,entity in ipairs(entities) do
for k,entity in pairs(entities) do
local distance = #(coords - GetEntityCoords(entity))
if distance <= maxDistance then
table.insert(nearbyEntities, entity)
table.insert(nearbyEntities, isPlayerEntities and k or entity)
end
end