Difference between revisions of "Initialization Order"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (added scripting topic category)
m (Page refresh)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Introduction ==
+
Whenever a mission is launched (or [[Join In Progress|joined]] in Multiplayer) certain tasks are performed to ensure the mission's various components are initialised correctly and that everyone is synced in multiplayer games (particularly [[JIP]] players).
 +
Initialisation order refers to the order in which those tasks are executed and it is important to take into account when setting up the start of a mission.
  
Whenever a mission is launched (or joined in multiplayer) certain tasks are performed to ensure the mission's various components are initialized correctly and that everyone is synced in multiplayer games (particularly [[JIP]] players). Initialization order refers to the order in which those tasks are executed and it's important to take into account when setting up the start of a mission.
+
[[Event Scripts]] are a key part of a mission's initialisation order and will be utilised often when working with [[SQF syntax|SQF]].
  
[[Event Scripts]] are a key part of a mission's initialization order and will be utilized often when working with [[SQF]].
 
  
== Arma 3 ==
+
{| class="bikitable" style="float: right; margin: 0 0 0.5em 1.5em"
 
 
Take note that the order of initialization is different in single player and multiplayer environments. If an entry is unmarked then it applies to both.
 
 
 
{| class="bikitable"
 
|-
 
 
|+ Key
 
|+ Key
!Item
+
! Item
!Meaning
+
! Meaning
 
|-
 
|-
|bgcolor="#95F0AD"|
+
| style="background-color: #95F0AD" |
|Single Player Only
+
| Single Player Only
 
|-
 
|-
|bgcolor="#95DEF0"|
+
| style="background-color: #95DEF0" |
|Multiplayer Only
+
| Multiplayer Only
 
|-
 
|-
|bgcolor="#DEF0AD"|
+
| style="background-color: #DEF0AD" |
|Order is not guaranteed
+
| Order is not guaranteed
 
|}
 
|}
 +
Take note that the order of initialisation is different in single player and multiplayer environments. If an entry is unmarked then it applies to both.
 +
{{Informative | In multiplayer the following is relevant to every machine including the server and [[Arma 3 Headless Client|headless clients]].
 +
If the server is non-dedicated then it should be considered both a server and client.}}
 +
  
In multiplayer the following is relevant to every machine including the server and [[Arma 3 Headless Client|headless clients]]. If the server is non-dedicated then it should be considered both a server and client.
+
{{Clear}}
 +
== Arma 3 ==
  
 
{| class="bikitable"
 
{| class="bikitable"
|-
+
|+ Order of Initialisation (From First to Last)
|+ Order of Initialization
 
 
! Task
 
! Task
 
! Applies To
 
! Applies To
Line 35: Line 34:
 
! Related To
 
! Related To
 
! Exec Environment
 
! Exec Environment
 +
! Notes
 
|-
 
|-
|Functions with ''recompile'' attribute are recompiled
+
| Functions with ''recompile'' attribute are recompiled
|All
+
| All
|
+
| {{task/}}
|[[Functions Library (Arma 3)]]
+
| [[Arma 3 Functions Library]]
 +
|
 
|
 
|
 
|-
 
|-
|Functions with ''preInit'' attribute are called
+
| Functions with ''preInit'' attribute are called
|All
+
| All
|
+
| {{task/}}
|[[Functions Library (Arma 3)]]
+
| [[Arma 3 Functions Library]]
|[[Scheduler#Unscheduled_Environment|Unscheduled]]
+
| [[Scheduler#Unscheduled Environment|Unscheduled]]
 +
|
 
|-
 
|-
|Object Init Event Handlers are called
+
| Object Init Event Handlers are called
|All
+
| All
 +
| {{task}}
 
|
 
|
 +
| [[Scheduler#Unscheduled Environment|Unscheduled]]
 
|
 
|
|[[Scheduler#Unscheduled_Environment|Unscheduled]]
 
 
|-
 
|-
|Expressions of Eden Editor entity attributes are called
+
| Expressions of Eden Editor entity attributes are called
|<!-- network -->
+
| <!-- network -->
|<!-- isJIP -->
+
| {{task}}
|[[Eden Editor: Configuring Attributes]]
+
| [[Eden Editor: Configuring Attributes]]
|[[Scheduler#Unscheduled_Environment|Unscheduled]]
+
| [[Scheduler#Unscheduled Environment|Unscheduled]]
 +
| They are called on the server. <code>[[isPlayer]] _entity;</code> does not return true immediately. Once entity has become a [[player]], the entity is transfered to the client.
 
|-
 
|-
|Object initialization fields are called
+
| Object initialisation fields are called
|All
+
| All
|
+
| {{task/}}
 +
|
 +
| [[Scheduler#Unscheduled Environment|Unscheduled]]
 +
|
 +
|- style="background-color: #95F0AD"
 +
| [[Event Scripts#init.sqs|init.sqs]] is executed
 +
| Singleplayer
 +
| <small>N/A</small>
 +
| [[Event Scripts]]
 +
|
 +
|
 +
|- style="background-color: #95F0AD"
 +
| [[Event Scripts#init.sqf|init.sqf]] is executed
 +
| Singleplayer
 +
| <small>N/A</small>
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits">Note that while the environment is [[Scheduler#Scheduled Environment|Scheduled]] ([[canSuspend]] returns true), the engine seems to wait until the script is done executing, essentially behaving similarly to an [[Scheduler#Unscheduled Environment|Unscheduled environment]] - infinite loops will freeze the game, uiSleep may pause the game for up to ~20secs (postInit), etc.</ref>
 
|
 
|
|[[Scheduler#Unscheduled_Environment|Unscheduled]]
 
 
|-
 
|-
|bgcolor="#95F0AD"| init.sqs is executed
+
| Expressions of Eden Editor scenario attributes are called
|bgcolor="#95F0AD"| Single Player
+
| All
|bgcolor="#95F0AD"|
+
| {{task/}}
|bgcolor="#95F0AD"| [[Event Scripts]]
+
| [[Eden Editor: Configuring Attributes]]
|bgcolor="#95F0AD"|
+
| [[Scheduler#Unscheduled Environment|Unscheduled]]
 +
| [[player]] is not available immediately.
 
|-
 
|-
|bgcolor="#95F0AD"| init.sqf is executed
+
| Persistent functions are called
|bgcolor="#95F0AD"| Single Player
+
| Client
|bgcolor="#95F0AD"|
+
| {{task/}}
|bgcolor="#95F0AD"| [[Event Scripts]]
+
| [[BIS_fnc_MP]]
|bgcolor="#95F0AD"|[[Scheduler#Scheduled_Environment|Scheduled]]<ref name="enginewaits">Note that while the environment is [[Scheduler#Scheduled_Environment|Scheduled]] ([[canSuspend]] returns true), the engine seems to wait until the script is done executing, essentially behaving similarly to an [[Scheduler#Unscheduled_Environment|Unscheduled environment]] - infinite loops will freeze the game, uiSleep may pause the game for up to ~20secs (postInit), etc.</ref>
+
|
 +
|
 
|-
 
|-
|Expressions of Eden Editor scenario attributes are called
+
| Modules are initialised
 
| All
 
| All
|
+
| {{task}}
|[[Eden Editor: Configuring Attributes]]
+
|
|[[Scheduler#Unscheduled_Environment|Unscheduled]]
+
|
|-
 
|Persistent functions are called
 
|Client
 
|✔
 
|[[BIS_fnc_MP]]
 
 
|
 
|
|-
+
|- style="background-color: #DEF0AD"
|Modules are initialized
+
| [[Event Scripts#initServer.sqf|initServer.sqf]] is executed
|All
+
| Server
 +
| <small>N/A</small>
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]
 
|
 
|
 +
|- style="background-color: #DEF0AD"
 +
| [[Event Scripts#initPlayerLocal.sqf|initPlayerLocal.sqf]] is executed
 +
| Client
 +
| {{task/}}
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]
 
|
 
|
 +
|- style="background-color: #DEF0AD"
 +
| [[Event Scripts#initPlayerServer.sqf|initPlayerServer.sqf]] is executed on the server
 +
| Client
 +
| {{task/}}
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]
 
|
 
|
 
|-
 
|-
|bgcolor="#DEF0AD"|initServer.sqf is executed
+
| Functions with ''postInit'' attribute are called
|bgcolor="#DEF0AD"|Server
+
| All
|bgcolor="#DEF0AD"|
+
| {{task/}}
|bgcolor="#DEF0AD"|[[Event Scripts]]
+
| [[Arma 3 Functions Library]]
|bgcolor="#DEF0AD"|[[Scheduler#Scheduled_Environment|Scheduled]]
+
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits"/>
 +
|
 
|-
 
|-
|bgcolor="#DEF0AD"|initPlayerLocal.sqf is executed
+
| "BIS_fnc_init" variable is set to true
|bgcolor="#DEF0AD"|Client
+
| All
|bgcolor="#DEF0AD"|✔
+
| {{task/}}
|bgcolor="#DEF0AD"|[[Event Scripts]]
+
| [[Arma 2: Functions Library]]
|bgcolor="#DEF0AD"|[[Scheduler#Scheduled_Environment|Scheduled]]
+
|
|-
 
|bgcolor="#DEF0AD"|initPlayerServer.sqf is executed on the server
 
|bgcolor="#DEF0AD"|Client
 
|bgcolor="#DEF0AD"|✔
 
|bgcolor="#DEF0AD"|[[Event Scripts]]
 
|bgcolor="#DEF0AD"|[[Scheduler#Scheduled_Environment|Scheduled]]
 
|-
 
|Functions with ''postInit'' attribute are called
 
|All
 
|
 
|[[Functions Library (Arma 3)]]
 
|[[Scheduler#Scheduled_Environment|Scheduled]]<ref name="enginewaits"/>
 
|-
 
|"BIS_fnc_init" variable is set to true
 
|All
 
|✔
 
 
|
 
|
 +
|- style="background-color: #95DEF0"
 +
| [[Event Scripts#init.sqs|init.sqs]] is executed
 +
| All
 +
| {{task/}}
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]
 +
|
 +
|- style="background-color: #95DEF0"
 +
| [[Event Scripts#init.sqf|init.sqf]] is executed
 +
| All
 +
| {{task/}}
 +
| [[Event Scripts]]
 +
| [[Scheduler#Scheduled Environment|Scheduled]]
 
|
 
|
|-
 
|bgcolor="#95DEF0"| init.sqs is executed
 
|bgcolor="#95DEF0"|All
 
|bgcolor="#95DEF0"|✔
 
|bgcolor="#95DEF0"|[[Event Scripts]]
 
|bgcolor="#95DEF0"|[[Scheduler#Scheduled_Environment|Scheduled]]
 
|-
 
|bgcolor="#95DEF0"|init.sqf is executed
 
|bgcolor="#95DEF0"|All
 
|bgcolor="#95DEF0"|✔
 
|bgcolor="#95DEF0"|[[Event Scripts]]
 
|bgcolor="#95DEF0"|[[Scheduler#Scheduled_Environment|Scheduled]]
 
 
|}
 
|}
 +
  
 
[[Category: Arma 3: Editing]]
 
[[Category: Arma 3: Editing]]
[[Category: Scripting_Topics ]]
+
[[Category: Scripting Topics]]

Latest revision as of 22:45, 15 September 2020

Whenever a mission is launched (or joined in Multiplayer) certain tasks are performed to ensure the mission's various components are initialised correctly and that everyone is synced in multiplayer games (particularly JIP players). Initialisation order refers to the order in which those tasks are executed and it is important to take into account when setting up the start of a mission.

Event Scripts are a key part of a mission's initialisation order and will be utilised often when working with SQF.


Key
Item Meaning
Single Player Only
Multiplayer Only
Order is not guaranteed

Take note that the order of initialisation is different in single player and multiplayer environments. If an entry is unmarked then it applies to both.

In multiplayer the following is relevant to every machine including the server and headless clients. If the server is non-dedicated then it should be considered both a server and client.


Arma 3

Order of Initialisation (From First to Last)
Task Applies To JIP Related To Exec Environment Notes
Functions with recompile attribute are recompiled All Ico ok.png Arma 3 Functions Library
Functions with preInit attribute are called All Ico ok.png Arma 3 Functions Library Unscheduled
Object Init Event Handlers are called All Ico none.png Unscheduled
Expressions of Eden Editor entity attributes are called Ico none.png Eden Editor: Configuring Attributes Unscheduled They are called on the server. isPlayer _entity; does not return true immediately. Once entity has become a player, the entity is transfered to the client.
Object initialisation fields are called All Ico ok.png Unscheduled
init.sqs is executed Singleplayer N/A Event Scripts
init.sqf is executed Singleplayer N/A Event Scripts Scheduled[1]
Expressions of Eden Editor scenario attributes are called All Ico ok.png Eden Editor: Configuring Attributes Unscheduled player is not available immediately.
Persistent functions are called Client Ico ok.png BIS_fnc_MP
Modules are initialised All Ico none.png
initServer.sqf is executed Server N/A Event Scripts Scheduled
initPlayerLocal.sqf is executed Client Ico ok.png Event Scripts Scheduled
initPlayerServer.sqf is executed on the server Client Ico ok.png Event Scripts Scheduled
Functions with postInit attribute are called All Ico ok.png Arma 3 Functions Library Scheduled[1]
"BIS_fnc_init" variable is set to true All Ico ok.png Arma 2: Functions Library
init.sqs is executed All Ico ok.png Event Scripts Scheduled
init.sqf is executed All Ico ok.png Event Scripts Scheduled
  1. 1.0 1.1 Note that while the environment is Scheduled (canSuspend returns true), the engine seems to wait until the script is done executing, essentially behaving similarly to an Unscheduled environment - infinite loops will freeze the game, uiSleep may pause the game for up to ~20secs (postInit), etc.