---
name: "addAction"
type: command
status: ok
groups: ["Interaction"]
arma3_since: "0.50"
locality: {"argument": "global", "effect": "local", "server_exec": false}
source: https://community.bistudio.com/wiki/addAction
revid: 378569
updated: 2026-05-08T21:16:48Z
---

# addAction

*Command · Interaction · Arma 3 v0.50*

Locality: arguments **global** · effect **local**

## Description

Adds an entry to the action menu of an object. The action can only be activated when in proximity to the object **and** looking at it. Adding an action to the player makes that action available to the player at all times. For event handling of user interaction see [inGameUISetEventHandler](../commands/inGameUISetEventHandler.md).

## Syntax

```sqf
object addAction [title, script, arguments, priority, showWindow, hideOnUse, shortcut, condition, radius, unconscious, selection, memoryPoint]
```

**Parameters:**

- **object**: [Object](../topics/Object.md) - unit, vehicle or static object. **No [agents](../commands/createAgent.md) and simple objects!**
- **title**: [String](../topics/String.md) - the action name displayed in the action menu, may contain [Structured Text](../topics/Structured_Text.md). Because of that **<** and **>** symbols will be interpreted as opening and closing XML tags. To avoid this use `<` for **<** and `>` for **>**. The title text appearance can be changed with [setUserActionText](../commands/setUserActionText.md)
- **script**: [String](../topics/String.md) or [Code](../topics/Code.md) - either path to the script file, relative to the mission folder or string with code or the actual script code. If the string is a path to script file, the script file **must** have extension .SQS or .[SQF](../topics/SQF_Syntax.md). The script, whether it is a file or a code, will run in [scheduled environment](../topics/Scheduler.md#scheduled-environment), i.e. it is ok to use [sleep](../commands/sleep.md). Parameters array passed to the script upon activation in *[_this](../topics/Magic_Variables.md#this)* variable is:

  ```sqf
  params ["_target", "_caller", "_actionId", "_arguments"];
  ```

  - **target**: [Object](../topics/Object.md) - the object which the action is assigned to
  - **caller**: [Object](../topics/Object.md) - the unit that activated the action
  - **actionID**: [Number](../topics/Number.md) - activated action's ID (same as [addAction](../commands/addAction.md)'s return value)
  - **arguments**: [Anything](../topics/Anything.md) - arguments given to the script if you are using the extended syntax
- **arguments**: [Anything](../topics/Anything.md) - (Optional, default [nil](../commands/nil.md)) arguments to pass to the script. Accessible with `_this select 3` inside the script. If [Array](../topics/Array.md) is used as an argument for example, its first element reference would be `_this select 3 select 0`
- **priority**: [Number](../topics/Number.md) - (Optional, default 1.5) priority value of the action. Actions will be arranged in descending order according to this value. Every game action has a preset priority value. Value can be negative or decimal fraction. Actions with same values will be arranged in order which they were made, newest at the bottom. The bigger the number the higher the action will be positioned on the menu. Typical range is 0 to 6
- **showWindow**: [Boolean](../topics/Boolean.md) - (Optional, default [true](../commands/true.md)) if set to [true](../commands/true.md), players see "Titletext" at mid-lower screen, as they approach the object. Only the title text for the action with highest priority and *showWindow* set to [true](../commands/true.md) will be shown
- **hideOnUse**: [Boolean](../topics/Boolean.md) - (Optional, default [true](../commands/true.md)) if set to [true](../commands/true.md), it will hide the action menu after selecting it. If set to [false](../commands/false.md), it will leave the action menu open and visible after selecting the action, leaving the same action highlighted, for the purpose of allowing you to re-select that same action quickly, or to select another action
- **shortcut**: [String](../topics/String.md) - (Optional, default "") one of the key names defined in bin.pbo (e.g. "moveForward"). Adding available shortcut will bind corresponding keyboard key to this action. Shortcut availability can be tested with [inputAction](../commands/inputAction.md) command
- **condition**: [String](../topics/String.md) - (Optional, default "true") expression that must return [true](../commands/true.md) for the action to be shown. **Special variables** passed to the script code are:
  - *_target*: [Object](../topics/Object.md) - The object to which action is attached or, if the object is a unit inside of vehicle, the vehicle
  - *_this*: [Object](../topics/Object.md) - Caller person to whom the action is shown (or not shown if *condition* returns [false](../commands/false.md))
  - *_originalTarget*: [Object](../topics/Object.md) - The original object to which the action is attached, regardless if the object/unit is in a vehicle or not
  - *_actionId*: [Number](../topics/Number.md) - checked action's ID (same as [addAction](../commands/addAction.md)'s return value)

  > [!WARNING]
  > If the player is the group leader, has an action added to them, and selects a subordinate, `*_this*` alternatively switches between the player and this selected unit - RPT logging `Unknown attribute itemsCmd` in the process.

  > [!IMPORTANT]
  > - *condition* is evaluated on each frame in [unscheduled environment](../topics/Scheduler.md#unscheduled-environment).
  > - *condition* is **not** evaluated if a dialog is open.
  > - If action is added to an object and not to the [player](../commands/player.md), *condition* will only get evaluated if the player is closer than ~50m to the object surface and is looking at the object.
  > - If action is added to [player](../commands/player.md), *condition* is evaluated all the time.
- **radius**: [Number](../topics/Number.md) - (Optional, default 50) maximum 3D [distance](../commands/distance.md) in meters between the activating unit's [eyePos](../commands/eyePos.md) and *object**s* memoryPoint*,* selection *or [position](../commands/position.md). -1 disables the radius; hardcoded limit is** 50*' *(since arma3 1.64)*
- **unconscious**: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) if [true](../commands/true.md) will be shown to incapacitated player. See also [setUnconscious](../commands/setUnconscious.md) and [lifeState](../commands/lifeState.md) *(since arma3 1.64)*
- **selection**: [String](../topics/String.md) - (Optional, default "") *object*'s geometry LOD's named selection *(since arma3 1.70)*
- **memoryPoint**: [String](../topics/String.md) - (Optional, default "") *object*'s memory point. If *selection* is supplied, *memoryPoint* is not used *(since arma3 1.82)*

**Returns:** [Number](../topics/Number.md) - the added action's ID. Action can be removed with [removeAction](../commands/removeAction.md) (see also [removeAllActions](../commands/removeAllActions.md)). IDs are incrementing, the first given action to each unit has the ID 0, the second the ID 1, etc. IDs are also passed to the called script (see the [*script* parameter](../commands/addAction.md#syntax-2))

## Examples

### Example 1

```sqf
// short and sweet
player addAction ["a useless action that does nothing", {}];
player addAction ["<t color='#FF0000'>This Useless Action Is RED</t>", { hint "RED" }];
player addAction ["Hint Hello!", { hint format ["Hello %1!", name player] }];
player addAction ["String Exec", "hint 'this is also compiled'"];
```

### Example 2

```sqf
_actionID = player addAction ["Exec the file", "scriptFile.sqf"];
```

**scriptFile.sqf:**

```sqf
hint str _this;
```

### Example 3

```sqf
// create object on the server and add action to the object on every client
if (isServer) then
{
    private _object = "some_obj_class" createVehicle [1234, 1234, 0];
    [_object, ["Greetings!", { hint "Hello!"; }]] remoteExec ["addAction"]; // Note: does not return action id
};
```

### Example 4

Default parameters:

```sqf
this addAction
[
    "title",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
    },
    nil,
    1.5,
    true,
    true,
    "",
    "true",
    50,
    false,
    "",
    ""
];
```

### Example 5

Default parameters with comments:

```sqf
this addAction
[
    "title",    // title
    {
        params ["_target", "_caller", "_actionId", "_arguments"]; // script
    },
    nil,        // arguments
    1.5,        // priority
    true,        // showWindow
    true,        // hideOnUse
    "",            // shortcut
    "true",        // condition
    50,            // radius
    false,        // unconscious
    "",            // selection
    ""            // memoryPoint
];
```

## Multiplayer

The command will be ignored on dedicated servers, probably because no UI exists.

## See also

[actionIDs](../commands/actionIDs.md) · [actionParams](../commands/actionParams.md) · [setUserActionText](../commands/setUserActionText.md) · [inGameUISetEventHandler](../commands/inGameUISetEventHandler.md) · [showHUD](../commands/showHUD.md) · [inputAction](../commands/inputAction.md) · [removeAction](../commands/removeAction.md) · [removeAllActions](../commands/removeAllActions.md) · [action](../commands/action.md) · [shownAction](../commands/shownAction.md) · [BIS_fnc_holdActionAdd](../functions/BIS_fnc_holdActionAdd.md)

## Community notes

**Dedmen** — 2018-05-02

If you want to replicate vanilla Actions like "Treat yourself" where the scroll menu only shows text and it displays the icon mid-screen you can use

```sqf
private _actionId = player addAction ["Heal", {}];
player setUserActionText [_actionId, "Heal", "<img size='2' image='\a3\ui_f\data\IGUI\Cfg\Actions\heal_ca'/>"];
```

---

**PierreMGI** — 2020-05-12

[addAction](../commands/addAction.md) on unit or player stays on corpse after kill. So this action is lost for the new body after respawn. If you want a persistent addAction, you need to add it in the respawn script ([onPlayerRespawn.sqf](../topics/Event_Scripts.md#onplayerrespawn-sqf) or [addMissionEventHandler](../commands/addMissionEventHandler.md) "entityRespawned" or addMPEventHandler "MPrespawn"...
You can use [removeAllActions](../commands/removeAllActions.md) on corpse.

---

**Leopard20** — 2022-08-28

If the server blocks [execVM](../commands/execVM.md) in CfgRemoteExec, you can't use path to script:

```sqf
_obj addAction ["Test", "path\script.sqf"]; // "path\script.sqf" won't execute
```

You can, however, do this:

```sqf
_obj addAction ["Test", { _this spawn compile preprocessFileLineNumbers "path\script.sqf" }];
```

But it's recommended to use functions if the script is called frequently.

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