Arma 3 Scripting

Command in Teams, Object Detection

agents

Also available as Markdown and JSON, or read the original wiki page.

Description

Return a list of agents in the current mission.

Syntax

agents

Returns: Array of Team Members

Examples

Example 1

{ agent _x moveTo position player } forEach agents;

Example 2

agents apply {typeOf agent _x}; // ["Snake_random_F","Snake_random_F","Snake_random_F","Rabbit_F"]

See also

teams · agent · createAgent · isAgent · forEachMemberAgent · entities · allCurators · allGroups · allDead · playableUnits · switchableUnits · vehicles · allUnitsUAV · allDeadMen

Community notes

Rocket

Note that agents returns a reference to the agent itself, not the object. For example:

{ alive _x } count agents;

would return an error But you can assign the agent a reference using setVariable, and then reference it, for example:

{ alive (_x getVariable ["agentObject", objNull]) } count agents;

would return the number of agents still alive - BUT you would need to define "agentObject" after you create the agent, for example:

_agent = createAgent [_type, _position, [], _radius, "NONE"];_agent setVariable["agentObject",_agent,true];
Killzone_Kid

Alternatively, to get object from agent reference use agent command.

PierreMGI

In debug console, pointing at an agent:

cursorObject;                                            // seems to refer to an agent (ex.: Agent 0xcbce41c0), but it is an object
teamMember cursorObject;                                // returns the same value Agent 0xcbce41c0, but now it is the agent
cursorObject in agents;                                    // will return false (even if you can read the value Agent 0xcbce41c0 in the agents array)
teamMember cursorObject in agents;                        // returns true. TeamMember allows to refer to the agent under the cursorObject
agent teamMember cursorObject isEqualTo cursorObject;    // true, same object.