Jump to content
Sign in to follow this  
sbsmac

Is there a way to playSound predefined CfgSfx?

Recommended Posts

It's been suggested that the CTF script pack I'm working on should use internal sounds by default. Looking inside sounds.pbo, it seems there are some handy sound-effects in the CfgSfx class. Eg:-

class AirAlarmSfx
{
 sounds[] = {"Alarm"};
 name = "$STR_DN_ALARM";
 Alarm[] = {"\ca\Sounds\sfx\air_raid",3.16228,1,300,1,0,0,0};
 empty[] = {"",0,0,0,0,0,0,0};
}; 

The problem is I can't figure out what syntax to use to play these with playsound. Trying

playsound "AirAlarmSfx" ;
playSound "\ca\Sounds\sfx\air_raid"
playSound "\ca\Sounds\sfx\air_raid.wss"

and other variations doesn't work. Any ideas ?

Share this post


Link to post
Share on other sites

Not possible to define as sounds in description.ext?

Share this post


Link to post
Share on other sites

I did try this but couldn't hit upon the right syntax. The naive approach of

class myAlarm

{

name = "myAlarm";

sound[] = {"\ca\Sounds\sfx\air_raid", 0,0};

titles[] ={} ;

};

didn't work. The 'internal' path is being interpreted as an external filepath.

Share this post


Link to post
Share on other sites

Did you try without leading slash?

class myAlarm
{
name = "myAlarm";
sound[] = {"ca\Sounds\sfx\air_raid", 0,0};
titles[] ={} ;
}; 

Either way, what is the error message from rpt?

Share this post


Link to post
Share on other sites

Unfortunately there is no error message produced in the rpt file, even when you deliberately mangle the path to try to force an error. For completeness, my entire cfgSounds is..

class CfgSounds

{

sounds[] = {myAlarm};

class myAlarm

{

name= "myAlarm";

sound[]={"\ca\Sounds\sfx\air_raid",db-1,db-1};

titles[] ={} ;

};

};

and I use 'playsound "myAlarm" ;' to try and play the sound

So far I've tried setting sound[] to

"\ca\Sounds\sfx\air_raid"

"ca\Sounds\sfx\air_raid"

"\ca\Sounds\sfx\air_raid.wss"

"ca\Sounds\sfx\air_raid.wss"

without any success. I suppose the problem may be with the volume levels - again I'm not entirely confident of the syntax here.

*Edit* and I'm aware that you need to reload the mission to get the editor to re-read description.ext.

Share this post


Link to post
Share on other sites

you are trying to define ingame sounds in a Description which isnt needed, The sounds are already defined, All you need to know is what name they use.

Share this post


Link to post
Share on other sites

Yes exactly. The point is though that the original name is defined as a CfgSfx in music.pbo so playSound won't work on it. Using description.ext is just a workaround. If you have a way to playSound CfgSfx sounds directly, I'd love to hear it! :-)

Share this post


Link to post
Share on other sites
Yes exactly. The point is though that the original name is defined as a CfgSfx in music.pbo so playSound won't work on it. Using description.ext is just a workaround. If you have a way to playSound CfgSfx sounds directly, I'd love to hear it! :-)

hmm looking into it :)

Share this post


Link to post
Share on other sites

Sorry for digging up age old thread, but there is little info on CfgSFX floating around, and most of it seems inaccurate or outdated.

My questions are:

1) What is the first number after the soundfile?

class CfgSFX
{
sounds[] = {};
class fx_light
{
	name = "fx_light";
	sounds[]={sound1}; //   "soundfile",?,pitch,volume,probability,min delay,mid delay,max delay
	sound1[]={"soundfx\power_light.wss",[b][color="Red"]1[/color][/b],1,5,1,0,0,0};
	empty[]= {"",0,0,0,0,0,0,0}; //For looping sounds
};
};

2. Has anyone decrypted the empty[] statement yet?

3. Why do we have to rely on decrypting? Why not info out in the open?

Share this post


Link to post
Share on other sites

I'm on the same page as all, Can't make the cfgSFX sounds play in game from a script.

Share this post


Link to post
Share on other sites

CfgSFX based sounds can only be played from triggers, and it is possible to play they from mission scripts by creating the triggers needed and setting their sound effect by assigning the sound effect to the trigger.

Two problems:

1) They are sometimes wacky, and I have no idea what is causing it. We need proper documentation for them.

2) The command setSoundEffect which you use to set sound effects for triggers, also need a dummy sound in the first slot, or you'll get an error message.

Example, script:

_pos = _this select 0;
_trigger = createTrigger ["EmptyDetector", _pos];
_trigger setTriggerStatements ["true", "", ""];
_trigger setSoundEffect ["[b][color="#ff0000"]NoSound[/color][/b]", "", "", [b][color="#ff0000"]fx_well[/color][/b]];

Example, description.ext:

class CfgSFX {
sounds[] = {};
class [b][color="Red"]fx_well[/color][/b] {name = "fx_well";sounds[]={sound1};sound1[]={"sounds\fx_well.ogg",1,1,50,1,0,0,0};empty[]= {"",0,0,0,0,0,0,0};};
};

class CfgSounds {
sounds[] = {};
class [b][color="#ff0000"]NoSound[/color][/b] {name = "NoSound";sound[] = {"", 0, 1};titles[] = {};}; //Dummy sound needed for setSoundEffect command, due to stupid bug in engine.
};

You have to create your own fx_well sound, which must be mono. And naturally define _pos somewhere.

Also read up on setSoundEffect: SoundDet (only for triggers) creates a dynamic sound object attached to a trigger defined in CfgSFX.

Edited by CarlGustaffa

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  

×