mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
Finished new code, closes #249
Co-Authored-By: Lén <corbeau.lenaic@gmail.com>
This commit is contained in:
@@ -57,6 +57,27 @@ local function EnumerateEntities(initFunc, moveFunc, disposeFunc)
|
||||
end)
|
||||
end
|
||||
|
||||
function EnumerateEntitiesWithinDistance(entities, coords, maxDistance)
|
||||
local nearbyEntities = {}
|
||||
|
||||
if coords then
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
else
|
||||
local playerPed = PlayerPedId()
|
||||
coords = GetEntityCoords(playerPed)
|
||||
end
|
||||
|
||||
for k,entity in ipairs(entities) do
|
||||
local distance = #(coords - GetEntityCoords(entity))
|
||||
|
||||
if distance <= maxDistance then
|
||||
table.insert(nearbyEntities, entity)
|
||||
end
|
||||
end
|
||||
|
||||
return nearbyEntities
|
||||
end
|
||||
|
||||
function EnumerateObjects()
|
||||
return EnumerateEntities(FindFirstObject, FindNextObject, EndFindObject)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user