Event Scripts

From Bohemia Interactive Community
Revision as of 22:46, 8 July 2010 by General Barron (talk | contribs) (removed reference to "version" number, since these referred to OFP versions and by now it is easier to assume everyone is not using OFP)
Jump to navigation Jump to search

Event scripts are 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).

The file extensions of the script depend on the used syntax. If you are using SQS syntax, the file extension is .sqs, else .sqf.

Note that the onPlayerKilled script must be in sqs syntax - if you write an onPlayerKilled.sqf, it won't be executed - the default onPlayerKilled.sqs contained in the ca.pbo file will get executed instead.

Available Scripts

init
Launched when mission is started (before briefing screen).
initIntro
Launched when intro is started .
exit
Launched when mission is finished (before debriefing screen).
One argument of type Number is passed to the script: The number of game end.
onFlare
Launched when illuminating shell is lit.
An array is passed to the script: [[r, g, b], gunner]
r, g, b: Number - the light color
gunner: Object - the unit who fired the flare shell
onPlayerKilled
Launched when the player dies permanently, and does not become a seagull.
Passed an array: [player, killer]
player: object - the player killed
killer: object - the unit that killed player - is the player in suicide/collision case
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.
In Armed Assault, 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.
onPlayerRespawnAsSeagull
Launched when the player dies and becomes a seagull.
Passed an array: [player, killer, seagull]
player: object - the player killed
killer: object - the unit that killed player - is the player in suicide/collision case
seagull: 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.
In Armed Assault, 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.
In Armed Assault, 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