Blitzen88 16 Posted June 25, 2020 Greetings, I use two sets of scripts to apply different equipment/guns/loadouts to AI groups. One script is a "loadout functions" script which creates functions which are used by other scripts which actually apply the loadout to the AI. This "loadout function" script is automatically run via the Init. Usually this works just fine but I have errors occur when an AI group execs a loadout script via its unit init box; I assume this is because unit init boxes exec before the init file. Is there a way to build in a check to the loadout scripts to see if a the loadout function script has run? Something like this: If ( loadoutFunctions.sqs has run ) then { (Do nothing) } else { exec LoadoutFunctions}; Share this post Link to post Share on other sites
gc8 970 Posted June 25, 2020 17 minutes ago, Blitzen88 said: Is there a way to build in a check to the loadout scripts to see if a the loadout function script has run? It's possible but i haven't written code for sqs (only sqf) so I cant give you any code for that. One option however is to declare your functions in functions library: https://community.bistudio.com/wiki/Arma_3_Functions_Library Then the functions are ready to be used from unit's init 1 Share this post Link to post Share on other sites
pierremgi 4738 Posted June 25, 2020 Are you trying to script for multiplayer (just a question)? Anyway, have a look at this page for initialization order. Try to write in SQF. SQS is outdated for a while. As you can read SQFs can return a variable and it's also a good way to know if a code is done. But here, I'm sure you can proceed in a smarter way, especially for single player. 1 Share this post Link to post Share on other sites
Blitzen88 16 Posted June 25, 2020 31 minutes ago, pierremgi said: Are you trying to script for multiplayer (just a question)? Anyway, have a look at this page for initialization order. Try to write in SQF. SQS is outdated for a while. As you can read SQFs can return a variable and it's also a good way to know if a code is done. But here, I'm sure you can proceed in a smarter way, especially for single player. It would be for singleplayer Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 25, 2020 you could use scriptDone as mentioned by @pierremgi by spawning your sqs script and storing the handle. Or u set a global variable at the end of ur sqs script and then test if it exists. In that case ur init field could look like: [] spawn { waitUntil {sleep 0.1; !isNil {yourGlobalVariable} }; // here your code to start scripts after init is run }; Share this post Link to post Share on other sites
Blitzen88 16 Posted June 25, 2020 1 hour ago, sarogahtyp said: you could use scriptDone as mentioned by @pierremgi by spawning your sqs script and storing the handle. Or u set a global variable at the end of ur sqs script and then test if it exists. In that case ur init field could look like: [] spawn { waitUntil {sleep 0.1; !isNil {yourGlobalVariable} }; // here your code to start scripts after init is run }; This is the approach I was considering. Define a global variable in the loadout function script and then check for that variable in the loadout scripts. Share this post Link to post Share on other sites
pierremgi 4738 Posted June 25, 2020 As reminder, you have also the already BIS_fnc_init variable as you can read in the initialization order (link above) So: 0 = this spawn { waitUntil {!isNil "bis_fnc_init"}; <your code with _this as variable here to apply loadout>}; 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 25, 2020 Are u sure that isnil check is enough with it? @pierremgi i thougth there has to be a check if its true as well... Share this post Link to post Share on other sites
pierremgi 4738 Posted June 26, 2020 4 hours ago, sarogahtyp said: Are u sure that isnil check is enough with it? @pierremgi i thougth there has to be a check if its true as well... I think this variable is directly set to true when defined, never false. https://community.bistudio.com/wiki/Functions_Library#Usage But you can check it for true: waitUntil {!isnil "bis_fnc_init" && {bis_fnc_init}}; Share this post Link to post Share on other sites