{"name":"createTrigger","operator":null,"title":"createTrigger","type":"command","url":"https://community.bistudio.com/wiki/createTrigger","revid":370090,"updated":"2024-10-31T19:20:48Z","groups":["Triggers"],"status":"ok","replaced_by":[],"games":[{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.\n\n> [!IMPORTANT]\n> 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.\n\n> [!NOTE]\n> Since Arma 3 v1.54 triggers can be disabled/enabled using enableSimulation command.\n\nTriggers are created with default parameters:\n- `a`: 50\n- `b`: 50\n- `c`: -1\n- `angle`: 0\n- `rectangular`: false\n- `activationBy`: None\n- `activationType`: Present\n- `repeating`: false\n- `timeoutMin`: 0\n- `timeoutMid`: 0\n- `timeoutMax`: 0\n- `interruptable`: true\n- `type`: None\n- `text`: \"\"\n- `name`: \"\"\n- `expCond`: \"this\"\n- `expActiv`: \"\"\n- `expDesactiv`: \"\"\n- Arma 3 v1.98 `interval`: 0.5","syntaxes":[{"syntax":"createTrigger [type, position, makeGlobal]","since":null,"effect":null,"exec":null,"params":[{"name":"type","type":"String","optional":false,"default":null,"description":"usually \"EmptyDetector\"","types":["String"],"since":null,"text":"type: String - usually \"EmptyDetector\""},{"name":"position","type":null,"optional":false,"default":null,"description":"Position2D, Position3D or Object (see the note in description)","types":["Position2D","Position3D","Object"],"since":null,"text":"position: Position2D, Position3D or Object (see the note in description)"},{"name":"makeGlobal","type":"Boolean","optional":true,"default":"true","description":"locality flag\n- true - trigger is global Global Effect\n- false - trigger is local Local Effect","types":["Boolean"],"since":"arma3 1.44","text":"makeGlobal: Boolean - (Optional - default true) locality flag\n- true - trigger is global Global Effect\n- false - trigger is local Local Effect"}],"returns":{"type":"Object","types":["Object"],"description":"created trigger","text":"Object - created trigger"},"form":"unary","operator":null,"left":null,"right":{"text":"[type, position, makeGlobal]","types":["Array"]}}],"examples":[{"text":"```sqf\n_trg = createTrigger [\"EmptyDetector\", getPos player];\n_trg setTriggerArea [5, 5, 0, false];\n_trg setTriggerActivation [\"CIV\", \"PRESENT\", true];\n_trg setTriggerStatements [\"this\", \"hint 'Civilian near player'\", \"hint 'no civilian near'\"];\n```","code":["_trg = createTrigger [\"EmptyDetector\", getPos player];\n_trg setTriggerArea [5, 5, 0, false];\n_trg setTriggerActivation [\"CIV\", \"PRESENT\", true];\n_trg setTriggerStatements [\"this\", \"hint 'Civilian near player'\", \"hint 'no civilian near'\"];"]},{"text":"Open/close Bar Gate automatically:\n\n```sqf\n//--- init of the Bar Gate\nif (isServer) then\n{    \n    _gateTrigger = createTrigger [\"EmptyDetector\", getPosWorld this, false];\n    _gateTrigger setVariable [\"BarGateObj\", this];\n    _gateTrigger setTriggerActivation [\"ANYPLAYER\", \"PRESENT\", true];\n    _gateTrigger setTriggerArea [5, 25, getDir this, true];\n    _gateTrigger setTriggerStatements \n    [\n        \"this\", \n        \"thisTrigger getVariable \"\"BarGateObj\"\" animateSource [\"\"Door_1_sound_source\"\", 1]\", \n        \"thisTrigger getVariable \"\"BarGateObj\"\" animateSource [\"\"Door_1_sound_source\"\", 0]\"\n    ];\n};\n```","code":["//--- init of the Bar Gate\nif (isServer) then\n{\t\n\t_gateTrigger = createTrigger [\"EmptyDetector\", getPosWorld this, false];\n\t_gateTrigger setVariable [\"BarGateObj\", this];\n\t_gateTrigger setTriggerActivation [\"ANYPLAYER\", \"PRESENT\", true];\n\t_gateTrigger setTriggerArea [5, 25, getDir this, true];\n\t_gateTrigger setTriggerStatements \n\t[\n\t\t\"this\", \n\t\t\"thisTrigger getVariable \"\"BarGateObj\"\" animateSource [\"\"Door_1_sound_source\"\", 1]\", \n\t\t\"thisTrigger getVariable \"\"BarGateObj\"\" animateSource [\"\"Door_1_sound_source\"\", 0]\"\n\t];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["setTriggerActivation","setTriggerArea","setTriggerStatements","setTriggerText","setTriggerTimeout","setTriggerType","setEffectCondition","setSoundEffect","setMusicEffect","setTitleEffect","deleteVehicle","synchronizeWaypoint","synchronizeTrigger","createGuardedPoint","triggerInterval","setTriggerInterval","enableSimulation","simulationEnabled"],"notes":[{"user":"TeaCup","date":"2013-03-06T14:15:00Z","text":"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."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Triggers","Introduced with Operation Flashpoint: Elite version 1.00","Operation Flashpoint: Elite: New Scripting Commands","Operation Flashpoint: Elite: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}