Kydoimos 916 Posted June 13, 2014 Hey all! Wondering if someone can help me with my frankly noobish scripting. Basically, I'm running an init.sqf that calls a couple of SQF files and contains a 15 second sleep, along with a bundle of animations etc. Now, my problem is, the first time I run the mission in the editor (and only the first time), the mission is sluggish and the OSD text appears later than it should and dialogue is getting delayed. I suspect the init.SQF is getting clogged. How can I run a series of sqfs for an intro without this happening? Strangely, I've used sqfs and sleeps in other missions, and have not had this problem. Any suggestions? Thanks very much in advance! ---------- Post added at 20:58 ---------- Previous post was at 20:52 ---------- The strangest thing is - it ONLY happens when I load Arma 3 and load the mission the first time! :p ---------- Post added at 21:03 ---------- Previous post was at 20:58 ---------- Scheduled scripts always start with slight delay, subject to engine load. I wonder if this is my problem? Share this post Link to post Share on other sites
Jigsor 176 Posted June 13, 2014 Not sure what the problem is exactly, but you may look into uiSleep. I've used it before in init.sqf and it helped delay map at briefing until everything was loaded. Had to play with exact amount of sleep. The A2 mission in my sig uses it. Share this post Link to post Share on other sites
R0T 1 Posted June 13, 2014 Are you getting any skript errors when you start it the first time ? Had the same problem with one of my scripts solution was just too wait for a function too get initialized Maybe this helps ! https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Initialization_Order Share this post Link to post Share on other sites
Kydoimos 916 Posted June 13, 2014 Interesting! I'll look into that! Thanks! Share this post Link to post Share on other sites
R0T 1 Posted June 13, 2014 Her is the thread with my problem ! http://forums.bistudio.com/showthread.php?t=179037 Share this post Link to post Share on other sites
Kydoimos 916 Posted June 13, 2014 Hi, ROT - no, there's no script errors or anything - thanks for the link! Share this post Link to post Share on other sites
zooloo75 834 Posted June 13, 2014 Can you post the mission here or your init.sqf? Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted June 14, 2014 Have you tried to launch all your scripts from a seperate .sqf file? Share this post Link to post Share on other sites
Kydoimos 916 Posted June 14, 2014 Hi Grumpy Old Man, I've tried that - yeah, doesn't seem to matter! ZooLoo75, might do that after work today. Thanks for your responses! Share this post Link to post Share on other sites
dna_uk 30 Posted June 14, 2014 The issue here is that on the first time you launch the mission the game is loading all the textures and objects for the first time, so the initial load is longer. Unfortunately while it's loading init.sqf has already been called and is executing. The only nice workaround I can think of right now is to use BIS_fnc_blackOut and BIS_fnc_blackIn; Try this at the very top of your init.sqf or initPlayerLocal.sqf: [ "BIS_ScreenSetup", false ] call BIS_fnc_blackOut; sleep 5; [ "BIS_ScreenSetup", true ] call BIS_fnc_blackIn; I actually use this in most of my missions just because it looks nicer anyway. Give it a go. Share this post Link to post Share on other sites
terox 316 Posted June 14, 2014 (edited) This may help. It will explain timings of some scripts and what occurs when. http://forums.bistudio.com/showthread.php?176096-Zeu-Debugging-Tutorial-amp-Foundation-Template Specifically, the following sections: Flow of code (Timing) A Little about code optimisation Edited June 14, 2014 by Terox Share this post Link to post Share on other sites
ceeeb 147 Posted June 14, 2014 You can use finishMissionInit, startLoadingScreen and endLoadingScreen to make sure as much initialisation as possible gets finished prior to the mission intro starting. Share this post Link to post Share on other sites
Azza FHI 50 Posted June 14, 2014 How do u use finishmissioninit? Share this post Link to post Share on other sites
Kydoimos 916 Posted June 14, 2014 Thanks everyone for your responses - yes, as Azer1234 asks, how exactly can the finishMissionInit be used? That sounds like it might do the trick! Share this post Link to post Share on other sites
katipo66 94 Posted June 14, 2014 The issue here is that on the first time you launch the mission the game is loading all the textures and objects for the first time, so the initial load is longer. Unfortunately while it's loading init.sqf has already been called and is executing.The only nice workaround I can think of right now is to use BIS_fnc_blackOut and BIS_fnc_blackIn; Try this at the very top of your init.sqf or initPlayerLocal.sqf: [ "BIS_ScreenSetup", false ] call BIS_fnc_blackOut; sleep 5; [ "BIS_ScreenSetup", true ] call BIS_fnc_blackIn; I actually use this in most of my missions just because it looks nicer anyway. Give it a go. Cool thanks. Share this post Link to post Share on other sites
Kydoimos 916 Posted June 14, 2014 Also, it seems the audio takes a while to process - for instance, the digital text sound on the OSD takes a while to materialise. Share this post Link to post Share on other sites
Kydoimos 916 Posted June 14, 2014 As a matter of fact, the OSD seems to take a lot of effort to process - even when I pre-process it. Really odd, that! Share this post Link to post Share on other sites
Kydoimos 916 Posted June 16, 2014 Plus, all the KB conversations are delayed at mission load. It's like there's a pause and then the audio needs to catch up. Share this post Link to post Share on other sites
ceeeb 147 Posted June 16, 2014 Thanks everyone for your responses - yes, as Azer1234 asks, how exactly can the finishMissionInit be used? That sounds like it might do the trick! I am not 100% certain, but my understanding is finishMissionInit is a nullary command, used in the same way one would use "waitUntil {scriptDone _scriptHandle}". It presumably suspends execution of the code until the mission initialisation is complete. Share this post Link to post Share on other sites
Kydoimos 916 Posted June 16, 2014 (edited) ---------- Post added at 12:00 ---------- Previous post was at 11:35 ---------- Thanks Ceeeb - that really helpful! Good to know! Edited June 16, 2014 by Kydoimos Share this post Link to post Share on other sites
neokika 62 Posted June 17, 2014 Hi there, This might be, because the rendering is still being loaded. Try: // Add event handler that fires once all systems (rendering, simulation etc) have been loaded and player is in control of character ["BIS_introPreload", "onPreloadFinished", { // Remove event handler ["BIS_introPreload", "onPreloadFinished"] call BIS_fnc_removeStackedEventHandler; // Flag missionNamespace setVariable ["BIS_readyForIntro", true]; }] call BIS_fnc_addStackedEventHandler; waitUntil { !isNil { missionNamespace getVariable "BIS_readyForIntro" }; }; // YOUR CODE GOES HERE Share this post Link to post Share on other sites