Jump to content
Sign in to follow this  
DJ_J3ff

Question, sounds

Recommended Posts

Hey folks, still learning here :) I had a hard time getting a sound file to work, kept getting a error about no "sound name.title". I finally found out why after going through quite a few pages of post in search. It was missing one curly bracket::confused:. Here is my file. For better understanding.

//===Class Identity==========
class CfgIdentities
{

 class Operator2
 {
  name="Operator2";
  face="Face54";
  glasses="Tactical";
  speaker="Male02";
  squad="";
  pitch=0.97293198;
   };

   class Operator3
   {
  name="Operator3";
  face="Face94";
  glasses="Tactical";
  speaker="Male03";
  squad="";
  pitch=0.97293198;
   };

   class Operator4
   {
  name="Operator4";
  face="Face44";
  glasses="Tactical";
  speaker="Male01";
  squad="";
  pitch=0.97293198;
   };
};



//===Music Section===========
class CfgMusic
{
tracks[]={Evildead,Lost Souls};

class Track1
{
	name="evildead"
		sound[]={\music\evildead.ogg,db+6, 1.0};
};

class Track2
{
	name="Lost Souls";
	sound[]={\music\Lost Souls.ogg,db+6, 1.0};
};
};

//===Sound Section==========
class CfgSounds
{
	sounds[]={Among_Ruins};
	class Among_Ruins 
	{
			name="Among_Ruins";
			sound[]={\sounds\Among_Ruins.ogg,db+6, 1.0};
	        titles[] =
	        {
               }; //<===why do I need 3?
       };         //<====Middle one

};                //<====Last

Most of the examples I saw had 2 curly brackets. Can someone explain to me please? I am still learning and I would not know what to put in search for this. Thanks a lot. I understand stuff in between the curly bracket is code,and the ; is a break, but why the need for middle one?

Share this post


Link to post
Share on other sites

It seems that you incorrect-recognize the corresponding parenthesis.

//===Sound Section==========
class CfgSounds
[color="SeaGreen"][b]{[/b][/color]
	sounds[]={Among_Ruins};
	class Among_Ruins 
	[color="Blue"][b][b]{[/b][/b][/color]
			name="Among_Ruins";
			sound[]={\sounds\Among_Ruins.ogg,db+6, 1.0};
	        titles[] =
	        [color="Red"][b]{[/b][/color]
               [color="Red"][b]};[/b][/color] //<===why do I need 3?
       [color="Blue"][b]};[/b][/color]         //<====Middle one

[color="SeaGreen"][b]};[/b][/color]                //<====Last

Share this post


Link to post
Share on other sites

It's like C++ code. You can find best information when googling for c++ syntax rules.

Or in short: every { that is 'opened' has to be closed somewhere } followed by a ;

To be able to write long code without forgetting to close something ppl tend to line opened and closed braces up:

class A
{
     class B
     {

              something = value of something;

     };

};

In this example above we've opened 2 braces so we need 2 closed ones at the end. Lining them up underneath each other is just good practice, that's all.

Class B is included inside Class A. You could also write it like this:

class A { class B { something = value of something; }; };

-> that would look horrible for longer classes. ;) For us humans that is.

However, that's exactly how the PC translates your classes. So the ; is needed to show him where a code line ends.

Edited by ])rStrangelove

Share this post


Link to post
Share on other sites

Ahhhhh I see it now. Thanks folks. Guess I will go back and re-type that section for the practice.:yay:

Just opened up Visual c++ 2008 Express, and found this in there ,C++ A Beginner’s Guide by Herbert Schildt. Seems like a good read so far.

Edited by DJ_J3ff

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  

×