---
name: "agents"
type: command
status: ok
groups: ["Teams", "Object Detection"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/agents
revid: 378915
updated: 2026-08-12T19:46:48Z
---

# agents

*Command · Teams, Object Detection · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Return a list of agents in the current mission.

## Syntax

```sqf
agents
```

**Returns:** [Array](../topics/Array.md) of [Team Member](../topics/Team_Member.md)s

## Examples

### Example 1

```sqf
{ agent _x moveTo position player } forEach agents;
```

### Example 2

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

## See also

[teams](../commands/teams.md) · [agent](../commands/agent.md) · [createAgent](../commands/createAgent.md) · [isAgent](../commands/isAgent.md) · [forEachMemberAgent](../commands/forEachMemberAgent.md) · [entities](../commands/entities.md) · [allCurators](../commands/allCurators.md) · [allGroups](../commands/allGroups.md) · [allDead](../commands/allDead.md) · [playableUnits](../commands/playableUnits.md) · [switchableUnits](../commands/switchableUnits.md) · [vehicles](../commands/vehicles.md) · [allUnitsUAV](../commands/allUnitsUAV.md) · [allDeadMen](../commands/allDeadMen.md)

## Community notes

**Rocket** — 2012-04-04

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

```sqf
{ alive _x } count agents;
```

 would return an error
 But you can assign the agent a reference using [setVariable](../commands/setVariable.md), and then reference it, for example: 

```sqf
{ 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:

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

---

**Killzone_Kid** — 2013-08-01

Alternatively, to get object from agent reference use [agent](../commands/agent.md) command.

---

**PierreMGI** — 2020-05-26

In debug console, pointing at an agent:

```sqf
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.
```

<sub>Source: [BI Community Wiki — agents](https://community.bistudio.com/wiki/agents) (revision 378915).</sub>
