Ranwer135 308 Posted July 4, 2015 Hey guys, I am having trouble with a script I made. What I'm trying to do is to play a sound at each sunset, that simple. (lets say 18.9 = 6:50 p.m.) Only problem is the "While" loop won't co-operate with me. :p Here is my code: (code is activated by "execVM") While {true} do { If (daytime > 18.9 && daytime < 16.4) then { _sounds = playSound ["NightFall_1", "NightFall_2", "NightFall_3", "NightFall_4"] call BIS_fnc_selectRandom; //Tracks are less than 10 seconds, therefore 1 track must be played at each sunset. sleep 10; }; }; Is there a way for the while loop to play once, and as soon as the track ends it calls the "while" loop again? Thanks, Rawner135 Share this post Link to post Share on other sites
Lala14 135 Posted July 4, 2015 use waitUntil? then execute it? then wait until its the next day via date? Share this post Link to post Share on other sites
Ranwer135 308 Posted July 4, 2015 Ok, I did what you suggested, the result ended up as once only. (I called it so that way it loops, but sadly it doesn't) Here is what I have now: _nightfall = waitUntil {daytime > 18.9 && daytime < 19}; _sounds = ["NightFall_1", "NightFall_2", "NightFall_3", "NightFall_4"] call BIS_fnc_selectRandom; playSound _sounds; waitUntil {call _nightfall}; Share this post Link to post Share on other sites
Lala14 135 Posted July 4, 2015 (edited) Ok,I did what you suggested, the result ended up as once only. (I called it so that way it loops, but sadly it doesn't) Here is what I have now: _nightfall = waitUntil {daytime > 18.9 && daytime < 19}; _sounds = ["NightFall_1", "NightFall_2", "NightFall_3", "NightFall_4"] call BIS_fnc_selectRandom; playSound _sounds; waitUntil {call _nightfall}; ok, that's not the correct way to do it. try this out. _fnc_sunsetNoises = { waitUntil {(daytime > 18.9 && daytime < 19) && ((missionNamespace getVariable ["day",-1]) != (date select 2))}; _sounds = ["NightFall_1", "NightFall_2", "NightFall_3", "NightFall_4"] call BIS_fnc_selectRandom; playSound _sounds; missionNamespace setVariable ["day",(date select 2)]; null = [] spawn _fnc_sunsetNoises; }; null = [] spawn _fnc_sunsetNoises; ---------- Post added at 16:33 ---------- Previous post was at 16:25 ---------- one thing I should add is that you should not use call with waitUntil or a while because they need to be started in a scheduled origin, if you did this you would get an error and that component of the script would not work, I suggest you put in the command line for arma 3 -showScriptErrors. However there are some instances where you can use call, if say for example you spawn some code, using call inside of that will work, but if you call the code in a non-scheduled scope it won't work, it's a bit complicated but if you look into the link underneath where MattAka Horner posted there it will help a lot. Edited July 4, 2015 by Lala14 accidentally used day instead of date Share this post Link to post Share on other sites
Ranwer135 308 Posted July 4, 2015 Thanks! Will try it out tonight. :) (I gotta use functions more in my mods :rolleyes:) Share this post Link to post Share on other sites
killzone_kid 1330 Posted July 4, 2015 are you planning on running your mission fore more than 24 hours non stop? Share this post Link to post Share on other sites
Ranwer135 308 Posted July 4, 2015 are you planning on running your mission fore more than 24 hours non stop? Yes, the mission will have fast time, so that means 24 hours will equal 1 hour. Share this post Link to post Share on other sites