Forum Jump :

Author Message


Posts: 1
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2020-09-29 23:26        
     
Hello all,

I am trying to make a music mod that uses different day time and weather parameters like "day", "night", "fog", "rain". I am trying to simplify the defining processes so I don't have to type in the song's class ID and duration twice.

Here is what I got here for a simplified example. The Musicplayer.sqf file is running under a loop from the previous segment in a different SQF.

Config.cpp cfgmusic section
class CfgMusic
{
	class Track1
	{
		sound[] = {"APT\Music\track1.ogg",1.0,1.0};
		duration = 100;

		parameters[]	= {"day", "rain"}; //I want to put each track into arrays specified by parameters
                                                   
	};

	class Track2
	{
		sound[] = {"APT\Music\track2.ogg",1.0,1.0};
		duration = 100;

		parameters[]	= {"night", "fog"}; 

	};


	class Track3
	{
		sound[] = {"APT\Music\track3.ogg",1.0,1.0};
		duration = 100;

		parameters[]	= {"rain"};

	};

	class Track4
	{
		sound[] = {"APT\Music\track4.ogg",1.0,1.0};
		duration = 100;

		parameters[]	= {"fog"};

	};


};



SQF that fires off Musicplayer.sqf
//Every second
while{true} do
{//Main Loop
{

         execVM "bf_Adapt\musicPlayer.sqf";
	 sleep(0.2);	
};


I know this looks incomplete but I'm sorta stumped on how to get the arrays specified into this.

Musicplayer.sqf
        if(isDay == 0)then
        {
                //playing music at night
                _selecter = floor(random count "night);
                playMusic (_stealthTracks select _selecter);
                duration =  getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
                currentTrack = (_stealthTracks select _selecter);
        };
        if(isDay == 1) then
        {
		//playing music during the day
		_selecter = floor(random count "day");
		playMusic (_safeTracks select _selecter);
		duration =  getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
		currentTrack = (_safeTracks select _selecter);
				
	};
			
	if(fog >= 0.3) then
	{
	        //playing fog music
		_selecter = floor(random count "fog");
		playMusic (_fogTracks select _selecter);
		duration =  getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
	        currentTrack = (_fogTracks select _selecter);
	};
			
	if(rain >= 0.5) then
	{
		//playing rain music
		_selecter = floor(random count "rain");
		playMusic (_rainTracks select _selecter);
		duration =  getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
		currentTrack = (_rainTracks select _selecter);
              
	};


I appreciate any help with this.

Thanks.






Tags: Cfgmusic, Music, Sound