Jump to content
Sign in to follow this  
tortuosit

Playmusic (with "playmusic" command) via mod

Recommended Posts

Hi,

I cannot get ArmA to play music at all. I want to play via a mod.

config.cpp inside the pbo has CfgMusic:

class Extended_PostInit_EventHandlers 
{
class TORT_playmusic
	{
	clientInit = "call compile preprocessFileLineNumbers '\TORT_playmusic\init.sqf'";
	disableModuload = true;
	};
};

class CfgMusic
{
	class test1
{
	name = "test1";
	sound[] = {"\TORT_playmusic\Music\test1.ogg", db+3, 1.0};
};
};

init.sqf has:

hint "TESTTEST";
playMusic "test1";

Hint appears, no music.

Music is here, example:

c:\Program Files (x86)\Steam\SteamApps\common\Arma 3\@tort_playMusic\Music\test1.ogg

Ideas? Music format is alright.

---------- Post added at 13:36 ---------- Previous post was at 13:27 ----------

Solved. Argh. Referenced sound file inside pbo, but they are outside. This is correct:

sound[] = {"\@TORT_playmusic\Music\test1.ogg", db+3, 1.0};

---------- Post added at 14:27 ---------- Previous post was at 13:36 ----------

Whats wrong here? Hint appears, music plays, but "Generic error in expression in line 7" - it does not want the sleep here.

hint "tort_PlayMusic running";
sleep 5;

while {true} do {
  //playmusic format ["tmusic_%1", ceil(random 37)];
  playmusic "tmusic_1";
  sleep 5;
};

---------- Post added at 14:38 ---------- Previous post was at 14:27 ----------

OK, it has to be inside a "0 = [] spawn {"

---------- Post added at 14:45 ---------- Previous post was at 14:38 ----------

NEW QUESTION:

How do I define the oggs length, I think in cfgmusic? If I know the tracks length, I know how long I have to wait at least. Before next track starts.

This is my simple main loop.

0 = [] spawn {
  sleep 5 + random 30;
  while {true} do {
     playmusic format ["tmusic_%1", ceil(random 37)];
     sleep 120 + random 120;
  };
};

ALSO, can I have ArmA count the number of files inside my sound folder?

And I wish I could make cfgmusic part somewhat adaptive.

Edited by tortuosit

Share this post


Link to post
Share on other sites

Great, never worked with eventhandlers, looks like that one is what I need.

That cfgmusic definition part is clunky, and unfortunately a very static thing and also has to be inside the pbo (config.cpp), not sure if it can be freed to description.ext when it's a mod. And that means, after all, a simple music playing mod can not be convenient. I have written a very simple one with "wait after init" min/max seconds and "waiting time until next" min/max seconds.

Best solution for convenience I found is, in cfgmusic I define tracks 1.ogg .. 100.ogg and user can simply put ogg files with those file names into a music folder. But due to cfgmusic inside pbo and music outside pbo, the addon folder can not be renamed or duplicated. I personally would love to use a per-mission sound addon, which will not work.

BASIC QUESTION! Is that really correct? To my knowledge, everything outside the pbo can only be referenced from inside the pbo via absolute or relative paths. But relative from Arma3Dir. So, the @addon folder can not be renamed.

Edited by tortuosit

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  

×