ScriptHook.GetEntitiesInRange

From Nomad DB
Revision as of 11:42, 2 August 2020 by Jan (talk | contribs) (Created page with "Returns a list of EntityId with entities around a given position & range. == Syntax == <syntaxhighlight lang="lua"> ScriptHook.GetEntitiesInRange(x, y, z, range) </syntax...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Returns a list of EntityId with entities around a given position & range.

Syntax

ScriptHook.GetEntitiesInRange(x, y, z, range)
  • x, y ,z number (Position)
  • range number (Range)

Example

Highlight all entities around the player position with a range of 20 units.

local entityId = GetLocalPlayerEntityId()
local xPos = GetEntityPosition(entityId, 0)
local yPos = GetEntityPosition(entityId, 1)
local zPos = GetEntityPosition(entityId, 2)

local outlineTable = ScriptHook.GetEntitiesInRange(xPos, yPos, zPos, 20)
for _,v in pairs(outlineTable) do
	StartEntityHighlight(v, 4)
end

Related Pages