Event Scripts: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
'''Event scripts''' are [[Script (Handle)|scripts]] which are fired by the game engine upon specific events. These scripts can be written in [[SQS syntax]] or [[SQF syntax]] ([[Armed Assault]] only, recommended).
'''Event scripts''' are [[Script (Handle)|scripts]] which are executed by the game engine upon specific events.


The file extensions of the script depend on the used syntax. If you are using [[SQS syntax]], the file extension is '''.sqs''', else '''.sqf'''.
To use an event script, create a file of given name in the [[Mission_Editor:_External|mission directory]].


Note that these scripts ''must'' be in [[sqs syntax]] - if you write an onPlayer*.sqf, it won't be executed - the default onPlayer*.sqs contained in the [[ca.pbo]] file will get executed instead. One easy way around this is to create both the .sqf and .sqs files, inside the .sqs files you can just put this piece of code
== Available Scripts ==


_this execVM onPlayer*.sqf
{| class="wikitable"
! File
! Description
! Arguments
! [[File:ofp_1.00.gif]]
! [[File:ofpr_1.75.gif]]
! [[File:arma_1.00.gif]]
! [[File:arma2_1.00.gif]]
! [[File:arma2oa_1.51.gif]]
! [[File:arma3_0.50.gif]]
! [[File:TKOH_1.00.gif]]


Remember to replace the * with the appropriate type.
|-
| ''init.sqs''
| Executed when mission is started (before briefing screen)
|
| ✔ <!-- OFP -->
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
| ✔ <!-- A3 -->
| ✔ <!-- TKOH -->


== Available Scripts ==
|-
| ''init.sqf''
| Executed when mission is started (before briefing screen)
|
| ✔ <!-- OFP -->
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
| ✔ <!-- A3 -->
| ✔ <!-- TKOH -->
 
|-
| ''initIntro.sqf''
| Executed when intro, outro win or outro lose is started.
|
| ✔ <!-- OFP -->
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
| ✔ <!-- A3 -->
| ✔ <!-- TKOH -->
 
|-
| ''exit.sqs''
| Executed when mission is finished (before debriefing screen). In Arma 3, "ended" [[addMissionEventHandler|mission event handler]] has the same functionality.
| <code>[endType:[[String]]]</code>
|  <!-- OFP -->
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
| ✔ <!-- A3 -->
| ✔ <!-- TKOH -->


; init
|-
: Launched when mission is started (before briefing screen).
| ''onFlare.sqs''
| Executed when a flare is lit after being fired from grenade launcher.
| <code>[colorRGB:[[Array]],shooter:[[Object]]]</code>
|  <!-- OFP -->
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
| ✔ <!-- A3 -->
| ✔ <!-- TKOH -->


; initIntro
|-
: Launched when intro is started.
| ''pauseOnLoad.sqf''
| Executed when pause menu is activated.


; exit
To make it work in MP, use ''onPauseScript = "myScript.sqf"'' in [[description.ext]]
: Launched when mission is finished (before debriefing screen).
| <code>[pauseMenuDisplay:[[Display]]]</code>
:
|  <!-- OFP -->
: One [[argument]] of type [[Number]] is passed to the script: The number of game end.
|  <!-- OFPR -->
|  <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
|  <!-- A3 -->
| ✔ <!-- TKOH -->


; onFlare
|-
: Launched when illuminating shell is lit.
| ''onPlayerKilled.sqs''
:
| Executed when player is killed in singleplayer or in multiplayer mission with "NONE" [[description.ext#respawn|respawn type]].
: An [[Array|array]] is passed to the script: [[r, g, b], gunner]
| <code>[player:[[Object]], killer:[[Object]]]</code>
:: r, g, b: [[Number]] - the light color
| ✔ <!-- OFP -->
:: gunner: [[Object]] - the unit who fired the flare shell
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
|  <!-- A3 -->
| ✔ <!-- TKOH -->


; onPauseScript
|-
: Since Arma 2 - launches ''pauseOnLoad.'''sqf''''' [http://forums.bistudio.com/showthread.php?108466-Detect-load-game-or-ESC-menu&p=1763523&viewfull=1#post1763523 ]
| ''onPlayerRespawnAsSeagull.sqs''
: Launched when pause menu is activated.
| 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.
: To make it work in MP, use ''onPauseScript = "myScript.sqf"'' in [[description.ext]]
| <code>[player:[[Object]], killer:[[Object]], seagull:[[Object]]]</code>
:
| ✔ <!-- OFP -->
: An [[Array|array]] is passed to the script: [ [[Display|display]] ]
| ✔ <!-- OFPR -->
| ✔ <!-- A1 -->
| ✔ <!-- A2 -->
| ✔ <!-- A2OA -->
|  <!-- A3 -->
| ✔ <!-- TKOH -->


; onPlayerKilled
|-
: Launched when the player dies permanently, and does not become a [http://community.bistudio.com/wikidata/images/archive/e/ed/20070308214324!Seagull.jpg seagull].
| ''onPlayerRespawnOtherUnit.sqs''
:
| 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.
: Passed an [[Array|array]]: [player, killer]
| <code>[player:[[Object]], killer:[[Object]], newPlayer:[[Object]]]</code>
::player: [[Object|object]] - the player killed
| ✔ <!-- OFP -->
::killer: [[Object|object]] - the unit that killed player - is the player in suicide/collision case
| ✔ <!-- OFPR -->
:
| ✔ <!-- A1 -->
: This script replaces the default death sequence. Make sure you place the command [[enableEndDialog]] somewhere in your script, as this will then cause the dialog that allows you to load, retry, or quit to appear.
| ✔ <!-- A2 -->
: Since ArmA this script is only executed if ''respawn'' in [[Description.ext]] is set to NONE (0). If respawn is set to some other value, then the onPlayerKilled script is not executed.
| ✔ <!-- A2OA -->
| <!-- A3 -->
| ✔ <!-- TKOH -->


; onPlayerRespawnAsSeagull
|}
: Launched when the player dies and becomes a [http://community.bistudio.com/wikidata/images/archive/e/ed/20070308214324!Seagull.jpg seagull].
:
: Passed an [[Array|array]]: [player, killer, seagull]
::player: [[Object|object]] - the player killed
::killer: [[Object|object]] - the unit that killed player - is the player in suicide/collision case
::seagull: [[Object|object]] - the seagull the player is about to possess.
:
: This script will replace the default seagulling sequence. Make sure you place the command [[enableEndDialog]] somewhere in your script, as this will then cause the dialog that allows you to load, retry, or quit to appear.
: Since ArmA this script is only executed if ''respawn'' in [[Description.ext]] is set to BIRD(1), or to GROUP (4) and all the group is dead.


; onPlayerRespawnOtherUnit
: Launched when the player dies and respawns into another unit member.
:
: Passed an array: [player, killer, new]
::player: [[object]] - the player killed
::killer: [[object]] - the unit that killed player
::new: [[object]] - the new unit the player is about to possess.
:
: This script will replace the default respawn sequence.
: Since ArmA, this script is only executed if ''respawn'' in [[Description.ext]] is set to GROUP (4) and there is another group member still alive.


== See also ==
== See also ==
* [[Script (File)]]
* [[Script (File)]]
* [[SQS syntax]]
* [[SQS syntax]]
Line 75: Line 136:


[[Category: Event Handlers]]
[[Category: Event Handlers]]
[[Category: Scripting_Topics ]]
[[Category: Scripting Topics]]
[[Category: Mission Editor]]
[[Category: Mission Editor]]
[[Category: Operation Flashpoint: Editing]]
[[Category: ArmA: Editing]]
[[Category: Arma 2: Editing]]
[[Category: Arma 3: Editing]]

Revision as of 09:56, 22 October 2013

Event scripts are scripts which are executed by the game engine upon specific events.

To use an event script, create a file of given name in the mission directory.

Available Scripts

File Description Arguments ofp 1.00.gif ofpr 1.75.gif arma 1.00.gif arma2 1.00.gif arma2oa 1.51.gif arma3 0.50.gif TKOH 1.00.gif
init.sqs Executed when mission is started (before briefing screen)
init.sqf Executed when mission is started (before briefing screen)
initIntro.sqf Executed when intro, outro win or outro lose is started.
exit.sqs Executed when mission is finished (before debriefing screen). In Arma 3, "ended" mission event handler has the same functionality. [endType:String]
onFlare.sqs Executed when a flare is lit after being fired from grenade launcher. [colorRGB:Array,shooter:Object]
pauseOnLoad.sqf Executed when pause menu is activated.

To make it work in MP, use onPauseScript = "myScript.sqf" in description.ext

[pauseMenuDisplay:Display]
onPlayerKilled.sqs Executed when player is killed in singleplayer or in multiplayer mission with "NONE" respawn type. [player:Object, killer:Object]
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. [player:Object, killer:Object, seagull:Object]
onPlayerRespawnOtherUnit.sqs Executed when player is killed in multiplayer mission with "GROUP" or "SIDE" respawn type. This script will replace the default respawn sequence. [player:Object, killer:Object, newPlayer:Object]


See also