Jump to content
Sign in to follow this  
Rommel

Order of Initialisation

Recommended Posts

AFAIK, the current order of initialisation is as follows:

* Units

o Units initialize in order of the mission.sqm. So it depends on which unit comes first in the mission.sqm, you can open it with a text editor to review

* Scripts

o Server & Players (NOT JIP)

+ While moving to Briefing

# Unit Init EH runs

# Unit Init line from editor runs

# After all units are initialized, init.sqf runs

+ After Briefing

+ if onPlayerConnected was setup in e.g. init.sqf, it will now process all the players connected in order of connected

# onPlayerConnected will process new players after they are connected to their player body. So JIP player connects, world initializes, he gets control of his character, now the onPlayerConnected fires on the server.

o JIP Players

+ Same as above, but there's no Briefing this time. init.sqf seems to run after the player gets control of his character

o Init.sqf

+ The init.sqf runs at the Briefing of the mission, as soon as the machine is ready to move into the Briefing. Or as JIP player after the initialization. So server/clients will not run them at the same time most of the time.

+ You can halt the processing of init.sqf during Briefing by adding a sleep or waitUntil (some condition, e.g: time > 0). This will wait until at least after the Briefing.

+ To my knowledge, there is no way to halt the game at the briefing until all init scripts have run and are finished

# You could however use a titleCut to blackIn and blackOut while your scripts are finishing initialization

But I've found a way to execute code even before the mission.sqm init line executions.

After a very annoying test of finding that 'groups' don't exist in this stage whlie testing around with 'condition of presence' with:

alive group leader this

I found you could like a waituntil loop, execute code within this block as long as a if statement existed at the end.

ie

hint format ["%1", leader group this]; isnull leader group this

Hinted in game a hexadecimal code, ie useless, but none the less an example.

No idea how you could use this, but you could execute scripts from here that run before the initialisation of the mission.sqm inits.

Share this post


Link to post
Share on other sites

How do you know it's being executed before the initialization of object init fields? I'm not doubting you, it probably does, but you never gave any evidence.

As for usefulness, probably not very, but good to know nonetheless.

Share this post


Link to post
Share on other sites

Well, I actually found a great use for this. I write a lot of code in the editor that I spawn (small stuff that isn't worth creating external scripts for) in unit's init fields. Usually I define a name for it so I don't have to copy code if using it on multiple units, but since I used to define it in an object's init field I had to make sure that object's init executed before the units who called that code. So I tried putting it in the condition of presence field, and it works great. As to keep things neat and tidy in the editor, I used a game logic's condition of presence, and made the condition evaluate to false (since the code still executed) as I don't need extra game logics sitting around in my mission.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×