Initialisation Order: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Includes Arma 3 information)
 
m (Lou Montana moved page Initialization Order to Initialisation Order: haaaaaaaaah.)
 
(44 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{Important|This page is currently a WIP (Work in Progress) and not in a finished state}}
Whenever a mission is launched (or [[Multiplayer Scripting#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 [[Multiplayer Scripting#Join In Progress|JIP]] players).
== Introduction ==
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="wikitable" style="float: right; margin: 0 0 0.5em 1.5em"
 
|+ Key
Be aware that a mission's initialization order is different depending on whether it's being ran in a single player or multiplayer environment.
! Item
 
! Meaning
=== Single Player ===
|-
 
| style="background-color: #95F0AD" |
# Functions with ''recompile'' attribute are recompiled
| Single Player Only
# Functions with ''preInit'' attribute are called
|-
# Object Init Event Handlers are called
| style="background-color: #95DEF0" |
# Object initialization fields are called
| Multiplayer Only
# init.sqs is executed
|-
# init.sqf is executed
| style="background-color: #DEF0AD" |
# Modules are initialized
| Order is not guaranteed
# Functions with postInit attribute are called
|}
# "BIS_fnc_init" variable is set to true
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.
{{Feature|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.
}}


=== Multiplayer ===


The following is relevant to every machine including the server itself and [[Arma 3 Headless Client|headless clients]]. If the server is non-dedicated then it should be considered both a server and client.
{{Clear}}
== {{arma3}} ==


{| class="bikitable"
{| class="wikitable"
|+ Order of Initialisation (From First to Last)
! Task
! Applies To
! JIP
! Related To
! Exec Environment
! Notes
|-
|-
! bgcolor="#ddddff" | Task
| Functions with ''recompile'' attribute are recompiled
! bgcolor="#ddddff" | Applies To
| All
! bgcolor="#ddddff" | JIP
| {{Icon|checked}}
! bgcolor="#ddddff" | Related To
| [[Arma 3: Functions Library]]
|
|
|-
|-
|Functions with ''recompile'' attribute are recompiled
| Functions with ''preInit'' attribute are called
|All
| All
|
| {{Icon|checked}}
|[[Functions Library (Arma 3)]]
| [[Arma 3: Functions Library]]
| [[Scheduler#Unscheduled Environment|Unscheduled]]
|
|-
|-
|Functions with ''preInit'' attribute are called
| Object Init Event Handlers are called
|All
| All
| {{Icon|unchecked}}
|
| [[Scheduler#Unscheduled Environment|Unscheduled]]
|
|
|[[Functions Library (Arma 3)]]
|-
|-
|Object Init Event Handlers are called
| Expressions of Eden Editor entity attributes are called
|All
| Server
| {{Icon|unchecked}}
| [[Eden Editor: Configuring Attributes]]
| [[Scheduler#Unscheduled Environment|Unscheduled]]
| <sqf inline>isPlayer _entity</sqf> does not return [[true]] immediately. Once the entity has become a [[player]], it is transfered to the client.
|-
| Object initialisation fields are called
| All
| {{Icon|checked}}
|
|
| [[Scheduler#Unscheduled Environment|Unscheduled]]
|
|- style="background-color: #95F0AD"
| [[Event Scripts#init.sqs|init.sqs]] is executed
| Singleplayer
| {{n/a}}
| [[Event Scripts]]
|
|
|- style="background-color: #95F0AD"
| [[Event Scripts#init.sqf|init.sqf]] is executed
| Singleplayer
| {{n/a}}
| [[Event Scripts]]
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits">Note '''in single player''' 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 ~20s (postInit), [[waitUntil]] can cause catastrophic issues, etc.</ref>
|
|
|-
|-
|Object initialization fields are called
| Expressions of Eden Editor scenario attributes are called
|All
| All
| {{Icon|checked}}
| [[Eden Editor: Configuring Attributes]]
| [[Scheduler#Unscheduled Environment|Unscheduled]]
| [[player]] is not available immediately.
|- style="background-color: #95DEF0"
| Persistent functions are called
| Client
| {{Icon|checked}}
| [[Arma 3: Remote Execution]], [[BIS_fnc_MP]]
|
|
|
|
|-
|-
|Persistent multiplayer functions are called
| Modules are initialised
|Client
| All
|
| {{Icon|unchecked}}
|[[BIS_fnc_MP]]
|
|-
|
|Modules are initialized
|
|All
|- style="background-color: #DEF0AD"
| [[Event Scripts#initServer.sqf|initServer.sqf]] is executed
| Server
| {{n/a}}
| [[Event Scripts]]
| [[Scheduler#Scheduled Environment|Scheduled]]
|
|- style="background-color: #DEF0AD"
| [[Event Scripts#initPlayerLocal.sqf|initPlayerLocal.sqf]] is executed
| Client
| {{Icon|checked}}
| [[Event Scripts]]
| [[Scheduler#Scheduled Environment|Scheduled]]
|
|
|- style="background-color: #DEF0AD"
| [[Event Scripts#initPlayerServer.sqf|initPlayerServer.sqf]] is executed on the server
| Client
| {{Icon|checked}}
| [[Event Scripts]]
| [[Scheduler#Scheduled Environment|Scheduled]]
|
|
|-
|-
|initServer.sqf is executed
| Functions with ''postInit'' attribute are called
|Server
| All
| {{Icon|checked}}
| [[Arma 3: Functions Library]]
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits"/>
|
|
|[[Event Scripts]]
|-
|-
|initPlayerLocal.sqf is executed
| "BIS_fnc_init" variable is set to true
|Client
| All
|
| {{Icon|checked}}
|[[Event Scripts]]
| [[Arma 2: Functions Library]]
|-
|
|initPlayerServer.sqf is executed on the server
|
|Client
|- style="background-color: #95DEF0"
|
| [[Event Scripts#init.sqs|init.sqs]] is executed
|[[Event Scripts]]
| Multiplayer
|-
| {{Icon|checked}}
|Functions with ''postInit'' attribute are called
| [[Event Scripts]]
|All
| [[Scheduler#Scheduled Environment|Scheduled]]
|
|
|[[Functions Library (Arma 3)]]
|- style="background-color: #95DEF0"
|-
| [[Event Scripts#init.sqf|init.sqf]] is executed
|"BIS_fnc_init" variable is set to true
| Multiplayer
|All
| {{Icon|checked}}
|
| [[Event Scripts]]
| [[Scheduler#Scheduled Environment|Scheduled]]
|
|
|-
|init.sqs is executed
|All
|✔
|[[Event Scripts]]
|-
|init.sqf is executed
|All
|✔
|[[Event Scripts]]
|}
|}
[[Category:Mission Editing]]
[[Category: Scripting Topics]]

Latest revision as of 19:31, 18 May 2023

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 Checked Arma 3: Functions Library
Functions with preInit attribute are called All Checked Arma 3: Functions Library Unscheduled
Object Init Event Handlers are called All Unchecked Unscheduled
Expressions of Eden Editor entity attributes are called Server Unchecked Eden Editor: Configuring Attributes Unscheduled isPlayer _entity does not return true immediately. Once the entity has become a player, it is transfered to the client.
Object initialisation fields are called All Checked 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 Checked Eden Editor: Configuring Attributes Unscheduled player is not available immediately.
Persistent functions are called Client Checked Arma 3: Remote Execution, BIS_fnc_MP
Modules are initialised All Unchecked
initServer.sqf is executed Server N/A Event Scripts Scheduled
initPlayerLocal.sqf is executed Client Checked Event Scripts Scheduled
initPlayerServer.sqf is executed on the server Client Checked Event Scripts Scheduled
Functions with postInit attribute are called All Checked Arma 3: Functions Library Scheduled[1]
"BIS_fnc_init" variable is set to true All Checked Arma 2: Functions Library
init.sqs is executed Multiplayer Checked Event Scripts Scheduled
init.sqf is executed Multiplayer Checked Event Scripts Scheduled
  1. 1.0 1.1 Note in single player 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 ~20s (postInit), waitUntil can cause catastrophic issues, etc.