Jump to content
Sign in to follow this  
 EO

Looping an ambient music script.

Recommended Posts

I have 5 pieces of music that will play during a scenario, so far everything checks out well with what I have, however, I would like to add a loop at the end of the script to rinse and repeat. 

 

This is what I have in my playmusic.sqf 

["1","playmusic",true,false] call BIS_fnc_MP;

sleep 213;

["2","playmusic",true,false] call BIS_fnc_MP;

sleep 237;

["3","playmusic",true,false] call BIS_fnc_MP;

sleep 374;

["4","playmusic",true,false] call BIS_fnc_MP;

sleep 244;

["5","playmusic",true,false] call BIS_fnc_MP;

sleep 239;

Any help with how to loop this script would be greatly appreciated.

Share this post


Link to post
Share on other sites

Hi EO, this should probably do the trick mate:

while {true} do
{
["1","playmusic",true,false] call BIS_fnc_MP;
sleep 213;

["2","playmusic",true,false] call BIS_fnc_MP;
sleep 237;

["3","playmusic",true,false] call BIS_fnc_MP;
sleep 374;

["4","playmusic",true,false] call BIS_fnc_MP;
sleep 244;

["5","playmusic",true,false] call BIS_fnc_MP;
sleep 239;
};
  • Like 1

Share this post


Link to post
Share on other sites

I use this script for my SP missions:

_track = _this select 0;
_repeat = _this select 1;
_onload = _this select 2;

removeAllMusicEventHandlers "MusicStop";
removeAllMissionEventHandlers "Loaded";

if (_repeat == 1) then {call compile format ["addMusicEventHandler ['MusicStop',{['%1', %2, %3] execVM 'music.sqf';}]", _track, _repeat, _onload];};
if (_onload == 1) then {call compile format ["addMissionEventHandler ['Loaded',{['%1', %2, %3] execVM 'music.sqf';}]", _track, _repeat, _onload];};

3 fademusic 0;
sleep 3.2;
playmusic format ["%1",_track];
3 fademusic 1;

It's not really what you need but it could give you some ideas. Change the

_track = _this select 0;

for some random / sequential track selection and you should be good. E.g.:

_tracks = ["some", "tracks", "here"];
call compile format ["addMusicEventHandler ['MusicStop',{_track = selectRandom %1; [_track] execVM 'music.sqf';}]", _tracks];
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the hints and tips guys.....those three little words from tpw were all I needed. Thanks mate.  ;)

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  

×