Arma 3 Scripting

createTrigger

  • Arma 3 v0.50
  • First in Operation Flashpoint: Elite v1.00

Command · Markdown · JSON · original wiki page

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 Objects, commands such as getPosASL, setPosASL, deleteVehicle 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 command.

Triggers are created with default parameters:

Syntax

createTrigger [type, position, makeGlobal]

Parameters:

Returns: Object - created trigger

Examples

Example 1

_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:

//--- 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 · setTriggerArea · setTriggerStatements · setTriggerText · setTriggerTimeout · setTriggerType · setEffectCondition · setSoundEffect · setMusicEffect · setTitleEffect · deleteVehicle · synchronizeWaypoint · synchronizeTrigger · createGuardedPoint · triggerInterval · setTriggerInterval · enableSimulation · simulationEnabled

Community notes

TeaCup

Calling list 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.