ScriptHook.GetEntitiesWithComponent
From Nomad DB
Revision as of 10:57, 2 August 2020 by Jan (talk | contribs) (Created page with "Returns a list of EntityId with the given components, see WD2 Entity Components for a list of available components. This function allows to specify any number of compo...")
Returns a list of EntityId with the given components, see WD2 Entity Components for a list of available components. This function allows to specify any number of components.
The first parameter is a boolean to specify whether the components are "inclusive":
- true = The entity must have all of the given components
- false = The entity must have at least one of the components
Syntax
ScriptHook.GetEntitiesWithComponent(inclusive, component1[, ..., componentN])
- inclusive: boolean
- component...:: string (component name)
Examples
The following snippet will receive all entities with a CCameraComponent
-- Note: the boolean has no effect, since only one component is provided
ScriptHook.GetEntitiesWithComponent(true, "CCameraComponent")
Get all entities which have at least one of the following components: CPhysComponent or CAgentComponent:
-- false = one of the two components is required
ScriptHook.GetEntitiesWithComponent(false, "CPhysComponent", "CAgentComponent")
Get all entities which have all of the following components: CLicensePlateComponent and CHackableVehicleComponent:
-- true = all of the components are required
ScriptHook.GetEntitiesWithComponent(true, "CLicensePlateComponent", "CHackableVehicleComponent")