Jump to content
ShadowRanger24

[Release] Auto Run Script

Recommended Posts

Not sure to understand why.

- initPlayerLocal.sqf is running on client who have interface anyway, not on dedi or Headless Client. So, if I'm right, the hasInterface condition in initPlayLocal.sqf is useless.

- the !isNull findDisplay 46  is usual. I missed that. But...  why a difference between hosted and dedicated server? They have, in I'm right, the same initialization order, and the fact a hosted server is also a client should not impact the process on other clients...

 

I'd really like to know why this solution works. Perhaps someone with better understanding than me could explain that to the community. Thanks.

  • Like 1

Share this post


Link to post
Share on other sites
On 4/21/2021 at 10:38 PM, pierremgi said:

Not sure to understand why.

- initPlayerLocal.sqf is running on client who have interface anyway, not on dedi or Headless Client. So, if I'm right, the hasInterface condition in initPlayLocal.sqf is useless.

- the !isNull findDisplay 46  is usual. I missed that. But...  why a difference between hosted and dedicated server? They have, in I'm right, the same initialization order, and the fact a hosted server is also a client should not impact the process on other clients...

 

I'd really like to know why this solution works. Perhaps someone with better understanding than me could explain that to the community. Thanks.

Have anyone figured out how to add autorun script to mission files?

Share this post


Link to post
Share on other sites
On 4/21/2021 at 10:38 AM, pierremgi said:

I'd really like to know why this solution works. Perhaps someone with better understanding than me could explain that to the community. Thanks.

I'm more than a year late seeing this so maybe you've already found the answer, but this is caused by race conditions created in user-scripts. The short answer is that display 46 just doesn't exist at the time that code runs, so no EH can be added. That can be easily checked with:

//in any "initX" script at the very beginning
with uiNamespace do {
	myVar = findDisplay 46;
};

uiNamespace getVariable "myVar" //put in console as a Watch variable; returns displayNull which is shown as "No display"

I can't give you the long answer as I am only knowledgeable enough with the initialization order to make my stuff work 😛

 

You may have realized this by now, but the actual important thing here and why it works is suspending the script with waitUntil allows time for the display to get created. You may already know that some commands just don't seem to work in init.sqf until it has been suspended in some way. Sleep will work just the same to create this effect. This is the exact reason why you'll see "sleep 0.001;" at the very beginning of so many of my init.sqf's

  • Like 1

Share this post


Link to post
Share on other sites

Yes, probably due to the client state chronology.

Even in initPlayerLocal.sqf, the client is already an entity (so player command works) before the player (guy who plays) has reached the display 46 (world display).

 

Share this post


Link to post
Share on other sites
12 hours ago, Tory Xiao said:

Have anyone figured out how to add autorun script to mission files?

Not sure to understand your question, but you just have to add some of these event scripts at mission root folder.

You can run your sqfs from them, if needed.

see also initialization order, especially for MP context.

 

 

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

×