| 
		
	
		| tyranius   Junior Member
 
 Posts: 23
 Threads: 6
 Joined: May 2011
 Reputation: 
0
 | 
			| I can never get sounds to work correctly! help me! 
 
				After a certain event happens I want to play a sound but it's not working at all. If I create a sound in the level editor it will play straight away even if I set it to not active, so I tried another approach and it's not working as well.
 void OnStart()
 {
 SetEntityCallbackFunc("display_1", "MonsterAppear");
 AddEntityCollideCallback("servant_grunt_1", "MonsterDisa", "MonsterGone", true, 1);
 }
 
 void MonsterAppear(string &in entity, string &in type)
 {
 GiveSanityDamage(30, true);
 PlaySoundAtEntity("Sound_2", "react_scare4.ogg", "Player", 0.1f, false);
 SetLightVisible("SpotLight_1", false);
 SetEntityActive("servant_grunt_1", true);
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 2, "");
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 2, "");
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 2, "");
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 2, "");
 AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 2, "");
 AddTimer("Timer1", 60, "MonsterGone");
 }
 
 void MonsterGone(string &in asTimer)
 {
 FadeEnemyToSmoke("servant_grunt_1", false);
 }
 
 Please help!
 |  |  
	| 05-12-2011, 07:52 PM |  |  
	
		| Acies   Posting Freak
 
 Posts: 1,643
 Threads: 60
 Joined: Feb 2011
 Reputation: 
73
 | 
			| RE: I can never get sounds to work correctly! help me! 
 
				Replace: PlaySoundAtEntity("Sound_2", "react_scare4.ogg", "Player", 0.1f, false);With: PlayGuiSound("react_scare.snt", 1.0);
 
  ![[Image: mZiYnxe.png]](http://i.imgur.com/mZiYnxe.png)  ジ
 |  |  
	| 05-12-2011, 07:55 PM |  |  
	
		| Roenlond   Senior Member
 
 Posts: 331
 Threads: 3
 Joined: Apr 2011
 Reputation: 
0
 | 
			| RE: I can never get sounds to work correctly! help me! 
 
				 (05-12-2011, 07:55 PM)Acies Wrote:  Replace: PlaySoundAtEntity("Sound_2", "react_scare4.ogg", "Player", 0.1f, false);With: PlayGuiSound("react_scare.snt", 1.0);
 
PlayGuiSound can only play .ogg files, no? I might be mistaken.
			 |  |  
	| 05-12-2011, 07:56 PM |  |  
	
		| Khyrpa   Senior Member
 
 Posts: 638
 Threads: 10
 Joined: Apr 2011
 Reputation: 
24
 | 
			| RE: I can never get sounds to work correctly! help me! 
 
				If you create a sound into the level editor, it works the same way as lights. Meaning you have to use:StopSound(string& asSoundName, float afFadeTime);
 at OnStart to mute the sound. Then to start it use:
 FadeInSound(string& asSoundName, float afFadeTime, bool abPlayStart);
 |  |  
	| 05-12-2011, 08:02 PM |  |  
	
		| Acies   Posting Freak
 
 Posts: 1,643
 Threads: 60
 Joined: Feb 2011
 Reputation: 
73
 | 
			| RE: I can never get sounds to work correctly! help me! 
 
				PlayGuiSound can play .snt files too    
I actually believe that the react_scare is a meant to be a gui sound and.. erm, a sound played as part of the player interface - such as the fall sounds, breathing, reactions etc.
			
  ![[Image: mZiYnxe.png]](http://i.imgur.com/mZiYnxe.png)  ジ
 |  |  
	| 05-12-2011, 08:11 PM |  |  
	
		| tyranius   Junior Member
 
 Posts: 23
 Threads: 6
 Joined: May 2011
 Reputation: 
0
 | 
			| RE: I can never get sounds to work correctly! help me! 
 
				Using PlayGuiSound worked thanks!
			 |  |  
	| 05-12-2011, 09:11 PM |  |  |