mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 10:48:52 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user