---
name: "createTrigger"
type: command
status: ok
groups: ["Triggers"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/createTrigger
revid: 370090
updated: 2024-10-31T19:20:48Z
---

# createTrigger

*Command · Triggers · Arma 3 v0.50 · introduced in Operation Flashpoint: Elite v1.00*

## Description

Creates a trigger of the given type and at the given position. The type must be a class name in *CfgNonAIVehicles* or *CfgVehicles* with `simulation = detector`. An array containing all units that have activated the trigger is available via `list triggerobj`. Since triggers are **[Object](../topics/Object.md)s**, commands such as [getPosASL](../commands/getPosASL.md), [setPosASL](../commands/setPosASL.md), [deleteVehicle](../commands/deleteVehicle.md) etc. work on them.

> [!IMPORTANT]
> Triggers are always created on the road surface (AGL) at provided x, y coordinates. The z param is ignored. In order to place the trigger with a custom z, use a 'setPosXXX' command after trigger creation.

> [!NOTE]
> Since Arma 3 v1.54 triggers can be disabled/enabled using [enableSimulation](../commands/enableSimulation.md) command.

Triggers are created with default parameters:
- `a`: 50
- `b`: 50
- `c`: -1
- `angle`: 0
- `rectangular`: false
- `activationBy`: None
- `activationType`: Present
- `repeating`: false
- `timeoutMin`: 0
- `timeoutMid`: 0
- `timeoutMax`: 0
- `interruptable`: true
- `type`: None
- `text`: ""
- `name`: ""
- `expCond`: "this"
- `expActiv`: ""
- `expDesactiv`: ""
- Arma 3 v1.98 `interval`: 0.5

## Syntax

```sqf
createTrigger [type, position, makeGlobal]
```

**Parameters:**

- `type`: [String](../topics/String.md) - usually "EmptyDetector"
- `position`: [Position2D](../topics/Position.md#introduction), [Position3D](../topics/Position.md#introduction) or [Object](../topics/Object.md) (see the note in description)
- `makeGlobal`: [Boolean](../topics/Boolean.md) - (Optional - default [true](../commands/true.md)) locality flag
  - [true](../commands/true.md) - trigger is global Global Effect
  - [false](../commands/false.md) - trigger is local Local Effect *(since arma3 1.44)*

**Returns:** [Object](../topics/Object.md) - created trigger

## Examples

### Example 1

```sqf
_trg = createTrigger ["EmptyDetector", getPos player];
_trg setTriggerArea [5, 5, 0, false];
_trg setTriggerActivation ["CIV", "PRESENT", true];
_trg setTriggerStatements ["this", "hint 'Civilian near player'", "hint 'no civilian near'"];
```

### Example 2

Open/close Bar Gate automatically:

```sqf
//--- init of the Bar Gate
if (isServer) then
{    
    _gateTrigger = createTrigger ["EmptyDetector", getPosWorld this, false];
    _gateTrigger setVariable ["BarGateObj", this];
    _gateTrigger setTriggerActivation ["ANYPLAYER", "PRESENT", true];
    _gateTrigger setTriggerArea [5, 25, getDir this, true];
    _gateTrigger setTriggerStatements 
    [
        "this", 
        "thisTrigger getVariable ""BarGateObj"" animateSource [""Door_1_sound_source"", 1]", 
        "thisTrigger getVariable ""BarGateObj"" animateSource [""Door_1_sound_source"", 0]"
    ];
};
```

## See also

[setTriggerActivation](../commands/setTriggerActivation.md) · [setTriggerArea](../commands/setTriggerArea.md) · [setTriggerStatements](../commands/setTriggerStatements.md) · [setTriggerText](../commands/setTriggerText.md) · [setTriggerTimeout](../commands/setTriggerTimeout.md) · [setTriggerType](../commands/setTriggerType.md) · [setEffectCondition](../commands/setEffectCondition.md) · [setSoundEffect](../commands/setSoundEffect.md) · [setMusicEffect](../commands/setMusicEffect.md) · [setTitleEffect](../commands/setTitleEffect.md) · [deleteVehicle](../commands/deleteVehicle.md) · [synchronizeWaypoint](../commands/synchronizeWaypoint.md) · [synchronizeTrigger](../commands/synchronizeTrigger.md) · [createGuardedPoint](../commands/createGuardedPoint.md) · [triggerInterval](../commands/triggerInterval.md) · [setTriggerInterval](../commands/setTriggerInterval.md) · [enableSimulation](../commands/enableSimulation.md) · [simulationEnabled](../commands/simulationEnabled.md)

## Community notes

**TeaCup** — 2013-03-06

Calling [list](../commands/list.md) immediately after creating a trigger this way (and setting up activation, area, statements, timeout, etc..), will return <null> instead of an array. It seems the trigger needs about 1 second to initialise, after which it will behave as expected: returning an array of all the objects inside the trigger (the ones matching the criteria), or an empty array.

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