| 
		
	
		| iLucian   Junior Member
 
 Posts: 22
 Threads: 8
 Joined: Jun 2013
 Reputation: 
0
 | 
			| RE: Help - Play Music when I touch an object 
 
				 (07-11-2013, 07:32 PM)The chaser Wrote:  Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this: 
 void Touch(string &in asEntity)
 {
 PlayMusic("music.ogg", false, 1, 1, 1, false);
 }
 
 
 
 Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.
 
that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.
 
  (07-11-2013, 07:32 PM)The chaser Wrote:  Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this: 
 void Touch(string &in asEntity)
 {
 PlayMusic("music.ogg", false, 1, 1, 1, false);
 }
 
 
 
 Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.
 
that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.
			 
 Wherever there is Light, Darkness has already gotten there first. 
				
(This post was last modified: 07-11-2013, 09:20 PM by iLucian.)
 |  |  
	| 07-11-2013, 09:17 PM |  |  
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| RE: Help - Play Music when I touch an object 
 
				Use this one instead: 
void Touch(string &in asEntity)
 
{
 
PlayMusic("music.ogg", true, 1, 0.1, 1, false);
 
}
 
That'll make the song loop   
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan. |  |  
	| 07-11-2013, 10:55 PM |  |  
	
		| iLucian   Junior Member
 
 Posts: 22
 Threads: 8
 Joined: Jun 2013
 Reputation: 
0
 | 
			| RE: Help - Play Music when I touch an object 
 
				 (07-11-2013, 10:55 PM)The chaser Wrote:  Use this one instead:
 
 
 void Touch(string &in asEntity)
 
 {
 
 PlayMusic("music.ogg", true, 1, 0.1, 1, false);
 
 }
 
 That'll make the song loop
  
No, i don't  want it to loop, when you touch the violin i want the song to play once  and then i want the music that was playing before you touched it to begin playing again. My problem is that the music when you touch the violin is looping even though i put false on the loop.
			 
 Wherever there is Light, Darkness has already gotten there first. 
				
(This post was last modified: 07-12-2013, 02:47 AM by iLucian.)
 |  |  
	| 07-12-2013, 02:44 AM |  |  
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| RE: Help - Play Music when I touch an object 
 
				Oh, I see. Then, do this: 
void Touch(string &in asEntity)
 
{
 
PlayMusic("music.ogg", false, 1, 0.1, 1, false);
 
AddTimer("", 7, "Replay");
 
}
 
void Replay (string &in asTimer) 
{ 
PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true); 
}
 
That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now   
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan. |  |  
	| 07-12-2013, 12:45 PM |  |  
	
		| iLucian   Junior Member
 
 Posts: 22
 Threads: 8
 Joined: Jun 2013
 Reputation: 
0
 | 
			| RE: Help - Play Music when I touch an object 
 
				 (07-12-2013, 12:45 PM)The chaser Wrote:  Oh, I see. Then, do this:
 void Touch(string &in asEntity)
 
 
 
 {
 
 PlayMusic("music.ogg", false, 1, 0.1, 1, false);
 
 AddTimer("", 7, "Replay");
 
 }
 
 void Replay (string &in asTimer)
 {
 PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true);
 }
 
 That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now
  
thanks for your help! Everything works fine now! thank you    
 Wherever there is Light, Darkness has already gotten there first. |  |  
	| 07-13-2013, 04:01 PM |  |  |