---
name: "BIS_fnc_addScriptedEventHandler"
type: function
status: ok
groups: ["Event Handlers"]
arma3_since: "1.00"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_addScriptedEventHandler
revid: 349191
updated: 2023-11-08T14:50:40Z
---

# BIS_fnc_addScriptedEventHandler

*Function · Event Handlers · Arma 3 v1.00*

## Description

Adds a Scripted Event Handler and returns its ID. Additionally, the "ScriptedEventHandlerAdded" Scripted EH is called. For the full list of all available Scripted EHs see [Arma 3: Scripted Event Handlers](../topics/Scripted_Event_Handlers.md).

## Syntax

```sqf
[namespace, name, code] call BIS_fnc_addScriptedEventHandler
```

**Parameters:**

- `namespace`: [Namespace](../topics/Namespace.md), [Object](../topics/Object.md), [Group](../topics/Group.md), [Location](../topics/Location.md), [Boolean](../topics/Boolean.md), [Control](../topics/Control.md) or [Display](../topics/Display.md) - namespace in which the EH is stored
- `name`: [String](../topics/String.md) - event name
- `code`: [Code](../topics/Code.md) or [String](../topics/String.md) - the code that is executed when the EH fires. The magic variable [_thisScriptedEventHandler](../topics/Magic_Variables.md#thisscriptedeventhandler) can be used to access the event handler ID within the code.

**Returns:** [Number](../topics/Number.md) - the ID of the new Event Handler

## Examples

### Example 1

```sqf
[missionNamespace, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;
```

### Example 2

```sqf
[true, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;
```

Boolean will default to [missionNamespace](../commands/missionNamespace.md).

## See also

[BIS_fnc_callScriptedEventHandler](../functions/BIS_fnc_callScriptedEventHandler.md) · [BIS_fnc_removeScriptedEventHandler](../functions/BIS_fnc_removeScriptedEventHandler.md) · [BIS_fnc_removeAllScriptedEventHandlers](../functions/BIS_fnc_removeAllScriptedEventHandlers.md)

<sub>Source: [BI Community Wiki — BIS fnc addScriptedEventHandler](https://community.bistudio.com/wiki/BIS_fnc_addScriptedEventHandler) (revision 349191).</sub>
