Event Scripts: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Add onFlare.sqs' projectile parameter)
m (Some wiki formatting)
Line 63: Line 63:
=== exit.sqf ===
=== exit.sqf ===
Executed when mission is finished (before debriefing screen). In Arma 3, "ended" [[addMissionEventHandler|mission event handler]] has the same functionality.
Executed when mission is finished (before debriefing screen). In Arma 3, "ended" [[addMissionEventHandler|mission event handler]] has the same functionality.
<syntaxhighlight lang="cpp">params ["_endType"];</syntaxhighlight>
<sqf>params ["_endType"];</sqf>
* endType: [[String]]
* endType: [[String]]
|  <!-- OFP -->
|  <!-- OFP -->
Line 78: Line 78:
=== exit.sqs ===
=== exit.sqs ===
Executed when mission is finished (before debriefing screen). In Arma 3, "ended" [[addMissionEventHandler|mission event handler]] has the same functionality.
Executed when mission is finished (before debriefing screen). In Arma 3, "ended" [[addMissionEventHandler|mission event handler]] has the same functionality.
<syntaxhighlight lang="cpp">params ["_endType"];</syntaxhighlight>
<sqf>params ["_endType"];</sqf>
* endType: [[String]]
* endType: [[String]]
|  <!-- OFP -->
|  <!-- OFP -->
Line 169: Line 169:
=== initPlayerLocal.sqf ===
=== initPlayerLocal.sqf ===
Executed locally when player joins mission (includes both mission start and JIP). See [[Initialization Order]] for details about when exactly the script is executed.
Executed locally when player joins mission (includes both mission start and JIP). See [[Initialization Order]] for details about when exactly the script is executed.
<syntaxhighlight lang="cpp">params ["_player", "_didJIP"];</syntaxhighlight>
<sqf>params ["_player", "_didJIP"];</sqf>
* player: [[Object]]
* player: [[Object]]
* didJIP: [[Boolean]]
* didJIP: [[Boolean]]
Line 186: Line 186:
Executed only on server when a player joins mission (includes both mission start and JIP). See [[Initialization Order]] for details about when exactly the script is executed.<br>
Executed only on server when a player joins mission (includes both mission start and JIP). See [[Initialization Order]] for details about when exactly the script is executed.<br>
This script relies on [[BIS_fnc_execVM]] and [[remoteExec]]. If [[CfgRemoteExec]]'s {{hl|class Functions}} is set to mode = 0 or 1, the script will never be executed. Therefore, initPlayerServer.sqf should be avoided.  Use [https://www.reddit.com/r/armadev/comments/8fkitd/initplayerserversqf_therefore_initplayerserversqf/dy5k5pf/ this method] instead.
This script relies on [[BIS_fnc_execVM]] and [[remoteExec]]. If [[CfgRemoteExec]]'s {{hl|class Functions}} is set to mode = 0 or 1, the script will never be executed. Therefore, initPlayerServer.sqf should be avoided.  Use [https://www.reddit.com/r/armadev/comments/8fkitd/initplayerserversqf_therefore_initplayerserversqf/dy5k5pf/ this method] instead.
<syntaxhighlight lang="cpp">params ["_playerUnit", "_didJIP"];</syntaxhighlight>
<sqf>params ["_playerUnit", "_didJIP"];</sqf>
* playerUnit: [[Object]]
* playerUnit: [[Object]]
* didJIP: [[Boolean]]
* didJIP: [[Boolean]]
Line 228: Line 228:
=== onFlare.sqs ===
=== onFlare.sqs ===
Executed when a flare is lit after being fired from grenade launcher.
Executed when a flare is lit after being fired from grenade launcher.
<syntaxhighlight lang="cpp">params ["_colorRGB", "_shooter", "_projectile];</syntaxhighlight>
<sqf>params ["_colorRGB", "_shooter", "_projectile];</sqf>
* colorRGB: [[Color|Color (RGBA)]]
* colorRGB: [[Color|Color (RGBA)]]
* shooter: [[Object]]
* shooter: [[Object]]
Line 245: Line 245:
=== onPlayerKilled.sqf ===
=== onPlayerKilled.sqf ===
Executed when player is [[Arma_3_Respawn#Files|killed]] in singleplayer or in multiplayer mission.
Executed when player is [[Arma_3_Respawn#Files|killed]] in singleplayer or in multiplayer mission.
<syntaxhighlight lang="cpp">params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];</syntaxhighlight>
<sqf>params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];</sqf>
* oldUnit: [[Object]]
* oldUnit: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 263: Line 263:
=== onPlayerKilled.sqs ===
=== onPlayerKilled.sqs ===
Executed when player is killed in singleplayer or in multiplayer mission with "NONE" [[Description.ext#respawn|respawn type]].
Executed when player is killed in singleplayer or in multiplayer mission with "NONE" [[Description.ext#respawn|respawn type]].
<syntaxhighlight lang="cpp">params ["_player", "_killer"];</syntaxhighlight>
<sqf>params ["_player", "_killer"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 279: Line 279:
=== onPlayerRespawn.sqf ===
=== onPlayerRespawn.sqf ===
Executed locally when player [[Arma_3_Respawn#Files|respawns]] in a multiplayer mission. This event script will also fire at the beginning of a mission if [[Description.ext#respawnOnStart|respawnOnStart]] is 0 or 1, oldUnit will be [[objNull]] in this instance. This script will not fire at mission start if [[Description.ext#respawnOnStart|respawnOnStart]] equals -1.
Executed locally when player [[Arma_3_Respawn#Files|respawns]] in a multiplayer mission. This event script will also fire at the beginning of a mission if [[Description.ext#respawnOnStart|respawnOnStart]] is 0 or 1, oldUnit will be [[objNull]] in this instance. This script will not fire at mission start if [[Description.ext#respawnOnStart|respawnOnStart]] equals -1.
<syntaxhighlight lang="cpp">params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];</syntaxhighlight>
<sqf>params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];</sqf>
* newUnit: [[Object]]
* newUnit: [[Object]]
* oldUnit: [[Object]]
* oldUnit: [[Object]]
Line 297: Line 297:
=== onPlayerRespawn.sqs ===
=== onPlayerRespawn.sqs ===
Executed when player is killed in multiplayer mission with "INSTANT" or "BASE" [[Description.ext#respawn|respawn type]]. It will not work if ''dta\scripts\onPlayerRespawn.sqs'' does not exist.
Executed when player is killed in multiplayer mission with "INSTANT" or "BASE" [[Description.ext#respawn|respawn type]]. It will not work if ''dta\scripts\onPlayerRespawn.sqs'' does not exist.
<syntaxhighlight lang="cpp">params ["_player", "_killer", "_respawnDelay"];</syntaxhighlight>
<sqf>params ["_player", "_killer", "_respawnDelay"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 315: Line 315:
Executed when player is killed in multiplayer mission with "SEAGULL" [[Description.ext#respawn|respawn type]], or when the type is "GROUP" or "SIDE", but no remaining respawn slots are left. This script will replace the default respawn sequence.
Executed when player is killed in multiplayer mission with "SEAGULL" [[Description.ext#respawn|respawn type]], or when the type is "GROUP" or "SIDE", but no remaining respawn slots are left. This script will replace the default respawn sequence.
{{Feature | arma3 | {{hl|playerRespawnSeagullScript.sqs}} in {{arma3}}.}}
{{Feature | arma3 | {{hl|playerRespawnSeagullScript.sqs}} in {{arma3}}.}}
<syntaxhighlight lang="cpp">params ["_player", "_killer", "_seagull"];</syntaxhighlight>
<sqf>params ["_player", "_killer", "_seagull"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 333: Line 333:
Executed when player is killed in multiplayer mission with "GROUP" or "SIDE" [[Description.ext#respawn|respawn type]]. This script will replace the default respawn sequence.
Executed when player is killed in multiplayer mission with "GROUP" or "SIDE" [[Description.ext#respawn|respawn type]]. This script will replace the default respawn sequence.
{{Feature|arma3|{{hl|playerRespawnOtherUnit.sqs}} in {{arma3}}.}}
{{Feature|arma3|{{hl|playerRespawnOtherUnit.sqs}} in {{arma3}}.}}
<syntaxhighlight lang="cpp">params ["_player", "_killer", "_newUnit"];</syntaxhighlight>
<sqf>params ["_player", "_killer", "_newUnit"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 351: Line 351:
Executed when player is respawned in multiplayer mission with "INSTANT" or "BASE" [[Description.ext#respawn|respawn type]]. It will not work if ''dta\scripts\onPlayerResurrect.sqs'' does not exist.
Executed when player is respawned in multiplayer mission with "INSTANT" or "BASE" [[Description.ext#respawn|respawn type]]. It will not work if ''dta\scripts\onPlayerResurrect.sqs'' does not exist.
{{Feature | arma3 | {{hl|playerResurrectScript.sqs}} in {{arma3}}.}}
{{Feature | arma3 | {{hl|playerResurrectScript.sqs}} in {{arma3}}.}}
<syntaxhighlight lang="cpp">params ["_player"];</syntaxhighlight>
<sqf>params ["_player"];</sqf>
* player: [[Object]]
* player: [[Object]]
| <!-- OFP -->
| <!-- OFP -->
Line 368: Line 368:


To make it work in MP or Arma 3, use <syntaxhighlight lang="cpp">onPauseScript = "pauseOnLoad.sqf";</syntaxhighlight> in [[Description.ext#onPauseScript|Description.ext]]
To make it work in MP or Arma 3, use <syntaxhighlight lang="cpp">onPauseScript = "pauseOnLoad.sqf";</syntaxhighlight> in [[Description.ext#onPauseScript|Description.ext]]
<syntaxhighlight lang="cpp">params ["_pauseMenuDisplay"];</syntaxhighlight>
<sqf>params ["_pauseMenuDisplay"];</sqf>
* pauseMenuDisplay: [[Display]]
* pauseMenuDisplay: [[Display]]
|  <!-- OFP -->
|  <!-- OFP -->
Line 383: Line 383:
=== playerKilledScript.sqs ===
=== playerKilledScript.sqs ===
Executed locally when player is killed in singleplayer or in multiplayer mission with "NONE" [[Description.ext#respawn|respawn type]]. Overrides default behavior of mission death screen in single player. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.
Executed locally when player is killed in singleplayer or in multiplayer mission with "NONE" [[Description.ext#respawn|respawn type]]. Overrides default behavior of mission death screen in single player. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.
<syntaxhighlight lang="cpp">params ["_player", "_killer"];</syntaxhighlight>
<sqf>params ["_player", "_killer"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 399: Line 399:
=== playerRespawnScript.sqs ===
=== playerRespawnScript.sqs ===
Executed locally and immediately when player is killed in multiplayer mission with "BASE" or "INSTANT" [[Description.ext#respawn|respawn type]]. Overrides default behavior of multiplayer respawn. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.
Executed locally and immediately when player is killed in multiplayer mission with "BASE" or "INSTANT" [[Description.ext#respawn|respawn type]]. Overrides default behavior of multiplayer respawn. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.
<syntaxhighlight lang="cpp">params ["_player", "_killer", "_respawnDelay"];</syntaxhighlight>
<sqf>params ["_player", "_killer", "_respawnDelay"];</sqf>
* player: [[Object]]
* player: [[Object]]
* killer: [[Object]]
* killer: [[Object]]
Line 416: Line 416:
=== teamSwitchScript.sqs ===
=== teamSwitchScript.sqs ===
Executed ''after'' a [[Team Switch]] is done. '''Not''' triggered by [[selectPlayer]].
Executed ''after'' a [[Team Switch]] is done. '''Not''' triggered by [[selectPlayer]].
<syntaxhighlight lang="cpp">params ["_oldUnit", "_newUnit"];</syntaxhighlight>
<sqf>params ["_oldUnit", "_newUnit"];</sqf>
* oldUnit: [[Object]]
* oldUnit: [[Object]]
* newUnit: [[Object]]
* newUnit: [[Object]]

Revision as of 13:35, 24 May 2022


Event Scripts are scripts that are executed upon specific events. Not all event scripts are executed directly by the engine.

To use an Event Script, create a file of the given name in the mission directory.

init* scripts (on)Player* scripts Other Scripts
See Initialization Order to learn when initialization scripts are executed.


Available Scripts

File Present in Details
Logo A0.png1.00 ofpr version.gif1.75 Logo A1 black.png1.00 Logo A2.png1.00 A2 OA Logo.png1.50 Arma 3 logo black.png1.00 tkoh logo small.png1.00 Can suspend

exit.sqf

Executed when mission is finished (before debriefing screen). In Arma 3, "ended" mission event handler has the same functionality.

params ["_endType"];

Checked Checked Checked Checked Checked

exit.sqs

Executed when mission is finished (before debriefing screen). In Arma 3, "ended" mission event handler has the same functionality.

params ["_endType"];

Checked Checked Checked Checked Checked Checked

init.sqf

Executed when mission is started (before briefing screen)

Checked Checked Checked Checked Checked Checked

init.sqs

Executed when mission is started (before briefing screen)

Checked Checked Checked Checked Checked Checked Checked

init3DEN.sqf

Executed when loading a scenario in Eden Editor if the file is present. Useful for executing scenario-specific editor functionality.

Checked Unchecked

initIntro.sqf

Executed when intro, outro win or outro lose is started.

Checked Checked Checked Checked

initIntro.sqs

Executed when intro, outro win or outro lose is started.

Checked Checked Checked Checked Checked Checked

initJIPcompatible.sqf

Executed locally by Arma 2: Multiplayer Framework when a player joins mission (includes both mission start and JIP). Also executed locally on server at mission start.

Checked Checked

initPlayerLocal.sqf

Executed locally when player joins mission (includes both mission start and JIP). See Initialization Order for details about when exactly the script is executed.

params ["_player", "_didJIP"];

Checked Checked

initPlayerServer.sqf

Executed only on server when a player joins mission (includes both mission start and JIP). See Initialization Order for details about when exactly the script is executed.
This script relies on BIS_fnc_execVM and remoteExec. If CfgRemoteExec's class Functions is set to mode = 0 or 1, the script will never be executed. Therefore, initPlayerServer.sqf should be avoided. Use this method instead.

params ["_playerUnit", "_didJIP"];

Checked Checked

initServer.sqf

Executed only on server when mission is started. See Initialization Order for details about when exactly the script is executed.

Checked Checked

missionFlow.fsm

Executed on post-init when mission is started. See BIS_fnc_missionFlow.

Checked

onFlare.sqs

Executed when a flare is lit after being fired from grenade launcher.

params ["_colorRGB", "_shooter", "_projectile];

Checked Checked Checked Checked Checked Checked

onPlayerKilled.sqf

Executed when player is killed in singleplayer or in multiplayer mission.

params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];

Checked Checked

onPlayerKilled.sqs

Executed when player is killed in singleplayer or in multiplayer mission with "NONE" respawn type.

params ["_player", "_killer"];

Checked Checked Checked Checked Checked Checked

onPlayerRespawn.sqf

Executed locally when player respawns in a multiplayer mission. This event script will also fire at the beginning of a mission if respawnOnStart is 0 or 1, oldUnit will be objNull in this instance. This script will not fire at mission start if respawnOnStart equals -1.

params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];

Checked Checked

onPlayerRespawn.sqs

Executed when player is killed in multiplayer mission with "INSTANT" or "BASE" respawn type. It will not work if dta\scripts\onPlayerRespawn.sqs does not exist.

params ["_player", "_killer", "_respawnDelay"];

Checked

onPlayerRespawnAsSeagull.sqs

Executed when player is killed in multiplayer mission with "SEAGULL" respawn type, or when the type is "GROUP" or "SIDE", but no remaining respawn slots are left. This script will replace the default respawn sequence.

Arma 3
playerRespawnSeagullScript.sqs in Arma 3.

params ["_player", "_killer", "_seagull"];

Checked Checked Checked Checked Checked Checked Checked

onPlayerRespawnOtherUnit.sqs

Executed when player is killed in multiplayer mission with "GROUP" or "SIDE" respawn type. This script will replace the default respawn sequence.

Arma 3
playerRespawnOtherUnit.sqs in Arma 3.

params ["_player", "_killer", "_newUnit"];

Checked Checked Checked Checked Checked Checked Checked

onPlayerResurrect.sqs

Executed when player is respawned in multiplayer mission with "INSTANT" or "BASE" respawn type. It will not work if dta\scripts\onPlayerResurrect.sqs does not exist.

Arma 3
playerResurrectScript.sqs in Arma 3.

params ["_player"];

Checked Checked

pauseOnLoad.sqf

Executed when pause menu is activated.

To make it work in MP or Arma 3, use
onPauseScript = "pauseOnLoad.sqf";
in Description.ext

params ["_pauseMenuDisplay"];

Checked Checked Checked Checked

playerKilledScript.sqs

Executed locally when player is killed in singleplayer or in multiplayer mission with "NONE" respawn type. Overrides default behavior of mission death screen in single player. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.

params ["_player", "_killer"];

? ? ? ? ? Checked ?

playerRespawnScript.sqs

Executed locally and immediately when player is killed in multiplayer mission with "BASE" or "INSTANT" respawn type. Overrides default behavior of multiplayer respawn. Game may become unplayable if not scripted correctly. Avoid use if not experienced with this script.

params ["_player", "_killer", "_respawnDelay"];

? ? ? ? ? Checked ?

teamSwitchScript.sqs

Executed after a Team Switch is done. Not triggered by selectPlayer.

params ["_oldUnit", "_newUnit"];

Checked
Additional initialization scripts can be executed using functions with preInit or postInit attribute.


Default Scripts Location

Game Path
Logo A0.png1.00 DTA/scripts.pbo
Logo A1 black.png1.00 Ca.pbo/data/scripts
Logo A2.png1.00
A2 OA Logo.png1.50
Arma 3 logo black.png1.00 functions_f.pbo/scripts
tkoh logo small.png1.00 data_h.pbo/data/scripts