Mudbill 
 
 
		
			Muderator 
			
			
			
 
			
	Posts: 3,881 
	Threads: 59 
	Joined: Apr 2013
	
 Reputation: 
179
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				Yes, put the PlayMusic line in either OnEnter or OnStart if you want it to play as soon as you appear in the map. If you put it in OnStart it will only start once (if you enter several times), but the music will keep playing throughout levels if you don't stop or change it.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 02-01-2015, 03:20 PM  | 
	
		
	 | 
 
 
	
		
		LDOriginal 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 35 
	Threads: 7 
	Joined: Oct 2014
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				void OnStart() 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 0.0f, false); 
PlayMusic("02_amb_safe.ogg", true, 1.0f, 0, 0, true); 
AddEntityCollideCallback("Player", "Flaska", "PlaySound", true, 1); 
AddEntityCollideCallback("Player", "Ljud", "start", true, 1); 
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true); 
 
} 
 
void UseKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked(asEntity, false, true); 
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false); 
RemoveItem(asItem); 
} 
 
void start(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 1, false); 
} 
 
void PlaySound(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "21_intro_scream.snt", "Player", 1, false); 
}
 
I was able to load the map but now when i enter an area general_piano01.snt, 02_amb_safe.ogg, 21_intro_scream.snt plays at the same time, lol. How does one separate these to play in their respective areas? I know you're suppose to name the area but i don't really see the solution in the script.
			  
			
			
			
				
(This post was last modified: 02-01-2015, 06:30 PM by LDOriginal.)
 
				
			 
		 |  
	 
 | 
 
	| 02-01-2015, 06:13 PM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				It's because you're starting "general_piano01" and "02_amb_safe" right as you start the map. When do you want these sounds/musics to start?
			 
			
			
 
Derp. 
			
				
(This post was last modified: 02-01-2015, 09:02 PM by Neelke.)
 
				
			 
		 |  
	 
 | 
 
	| 02-01-2015, 09:02 PM  | 
	
		
	 | 
 
 
	
		
		LDOriginal 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 35 
	Threads: 7 
	Joined: Oct 2014
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				 (02-01-2015, 09:02 PM)Neelke Wrote:  It's because you're starting "general_piano01" and "02_amb_safe" right as you start the map. When do you want these sounds/musics to start? 
Yeah i figured that out and managed to separate "21_intro_scream.snt" and "general_piano01.snt" to play in separately placed areas when i enter them. I guess i'm back to square one right now. I can't figure out how to write in the script so that music will start playing when i enter a certain area given on the map.
 
Using this one now:
 void OnStart() 
{ 
 
AddEntityCollideCallback("Player", "Flaska", "PlaySound", true, 1); 
AddEntityCollideCallback("Player", "Ljud", "start", true, 1); 
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true); 
 
} 
 
void UseKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked(asEntity, false, true); 
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false); 
RemoveItem(asItem); 
} 
 
void start(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 1, false); 
} 
 
void PlaySound(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "21_intro_scream.snt", "Player", 1, false); 
}
  
			 
			
			
			
		 |  
	 
 | 
 
	| 02-01-2015, 10:12 PM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				Maybe you need to add another collide function? (Another area to collide with). Or just put the music script in one of the functions. 
void start(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 1, false); 
PlayMusic("02_amb_safe.ogg", true, 1.0f, 0, 0, true); 
}
 
Or a new function:
 void OnStart() 
{ 
     AddEntityCollideCallback("Player", "AreaStartMusic", "CollideStartMusic", true, 1); 
} 
 
void CollideStartMusic(string &in asParent, string &in asChild, int alState) 
{ 
     PlayMusic("02_amb_safe.ogg", true, 1.0f, 0, 0, true); 
}
  
			 
			
			
 
Derp. 
			
		 |  
	 
 | 
 
	| 02-01-2015, 10:39 PM  | 
	
		
	 | 
 
 
	
		
		Mudbill 
 
 
		
			Muderator 
			
			
			
 
			
	Posts: 3,881 
	Threads: 59 
	Joined: Apr 2013
	
 Reputation: 
179
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				I would strongly advice against using nordic characters in your script. Try to make it as clean as possible. Using Æ Ø Å can mess with your script because the game doesn't know how to parse it.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 02-02-2015, 12:55 AM  | 
	
		
	 | 
 
 
	
		
		LDOriginal 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 35 
	Threads: 7 
	Joined: Oct 2014
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Help getting music to play in map 
			 
			
				 (02-01-2015, 10:39 PM)Neelke Wrote:  Maybe you need to add another collide function? (Another area to collide with). Or just put the music script in one of the functions. 
 
void start(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 1, false); 
PlayMusic("02_amb_safe.ogg", true, 1.0f, 0, 0, true); 
}
  
Or a new function: 
 
void OnStart() 
{ 
     AddEntityCollideCallback("Player", "AreaStartMusic", "CollideStartMusic", true, 1); 
} 
 
void CollideStartMusic(string &in asParent, string &in asChild, int alState) 
{ 
     PlayMusic("02_amb_safe.ogg", true, 1.0f, 0, 0, true); 
}
  
I honestly have no idea how to apply that to the existing script. Where would i put it? Thanks
  
 (02-02-2015, 12:55 AM)Mudbill Wrote:  I would strongly advice against using nordic characters in your script. Try to make it as clean as possible. Using Æ Ø Å can mess with your script because the game doesn't know how to parse it. 
Ok i will fix that, thank you.
 
 
Ok, got it working. Thanks guys!   
void OnStart() 
{ 
AddEntityCollideCallback("Player", "Musik", "CollideStartMusic", true, 1); 
AddEntityCollideCallback("Player", "Flaska", "PlaySound", true, 1); 
AddEntityCollideCallback("Player", "Ljud", "start", true, 1); 
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true); 
AddUseItemCallback("", "Tillskap", "Skap", "UseKeyOnDoor", true); 
 
} 
 
void UseKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked(asEntity, false, true); 
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false); 
RemoveItem(asItem); 
} 
 
void start(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "general_piano01.snt", "Player", 1, false); 
} 
 
void PlaySound(string &in asParent, string &in asChild, int alState) 
{ 
PlaySoundAtEntity("", "21_intro_scream.snt", "Player", 1, false); 
} 
 
void CollideStartMusic(string &in asParent, string &in asChild, int alState) 
{ 
     PlayMusic("02_amb_safe.ogg", false, 1.0f, 0, 0, true); 
}
  
			 
			
			
			
				
(This post was last modified: 02-02-2015, 04:40 PM by LDOriginal.)
 
				
			 
		 |  
	 
 | 
 
	| 02-02-2015, 04:06 PM  | 
	
		
	 | 
 
 
	 
 |