Jump to content
Sign in to follow this  
soul_assassin

Eventhandler vs editor init

Recommended Posts

I have the following very annoying problem:

- The random number and marking script is (A.sqf) hooked up via the config eventhandler init. It works perfectly.

There is a second script (B.sqf) which allows you to set a custom number/markings via some parameters in the editor init. This script works fine too, this was checked by putting the param line into a trigger init and then driving into the trigger.

The problem arises as the eventhandler is run AFTER the editor init line. So the numbers are set correctly through B and then instantly randomised through A rendering putting params in the init in the editor virtually useless. How do I bypass this?

Share this post


Link to post
Share on other sites

I did something like this for ArmA 1 but parsed the unit name to set the texture and number, so like: T72_DESERT_067. You could get script A.sqf to do the same or fallback to random numbers if the name doesn't match that pattern.

Share this post


Link to post
Share on other sites

An easy way would be to have your script wait until after the eventhandler is finished. This can easily be done by using variables, but it might not be the best method of archiving this.

Anyways, here's a rough sketch of what to do:

In your eventhandler, add the following line at the end of the file:

_vehicle setVariable ["initDone",true];

In the init script put this line right after you've initialized the variables:

waitUntil { !isNil call compile "_vehicle getVariable ""initDone"";" };

What this does.. the eventhandler sets the variable initDone to true, and the init-line scripts waits for exactly that until it continues executing.

You might have to redo the script commands a bit here and then, due to the time and the amount of alcohol ;)

Anyways, you should get the idea ;)

Edited by TeRp

Share this post


Link to post
Share on other sites

It didnt work :(

putting this line:

waitUntil { !isNil call compile "_vehicle getVariable ""initDone"";" };

makes B even in the trigger not work. Is there really no way to reverse the order? How retarded is that? It used to be fine in OFP and ArmA1

Share this post


Link to post
Share on other sites
It used to be fine in OFP and ArmA1

it was like that in OFP and Arma1.

One way is to call the scripts in a different way. In your config init event, use the call command to execute the code. That way it will kick in straight away.

From your mission editor init event, use execVM or Spawn. So the script will only be called after the config init event.

Share this post


Link to post
Share on other sites

execVM is used for both currently, thnx UNN ill give it a try. So the Syntax of the EH init should be:

_bmdinit = loadfile "BMDInit.sqf"; call compile _bmdinit;

is that about right?

Edited by Soul_Assassin

Share this post


Link to post
Share on other sites

Well this will do ok:

init="_this call compile preProcessFile ""BMDInit.sqf""";

Assuming there is nothing in BMDInit.sqf that won't work with the call command.

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  

×