Difference between revisions of "ScriptHook.GetEntitiesInRange"
From Nomad DB
(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...") |
(No difference)
|
Revision as of 11:42, 2 August 2020
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