Gamemakingdude 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 470 
	Threads: 82 
	Joined: Nov 2010
	
 Reputation: 
9
		
	 | 
	
		
			
Random sound at random time script help 
			 
			
				void OnStart() {     SetGlobalVarInt("Globalvar1", 0);     AddTimer("GlobalCheck", 0, "DoorCheck");     Addtimer("RandomSound",1.0f,"StartTiming"); }
  void StartTiming(string &in asTimer) {     int Time = RandInt(1,5);     string TimeName = "";     if(Time == 1) {         TimeName = "1";         }     if(Time == 2) {         TimeName = "2";         }     if(Time == 3) {         TimeName = "3";         }     if(Time == 4) {         TimeName = "4";         }     if(Time == 5) {         TimeName = "5";         }     AddTimer(TimeName,RandFloat(0,60),"SoundTime"); } void SoundTime(string &in asTimer) {     string x = asTimer;     if(x=="1") {         Addtimer("RandomSound",1.0f,"StartTiming");         PlaySoundAtEntity("","walkandgrunt.snt","Player",0,false);     }     if(x=="2") {         Addtimer("RandomSound",1.0f,"StartTiming");         PlaySoundAtEntity("","walkandgrunt.snt","Player",0,false);     }     if(x=="3") {         Addtimer("RandomSound",1.0f,"StartTiming");         PlaySoundAtEntity("","walkandgrunt.snt","Player",0,false);     }     if(x=="4") {         Addtimer("RandomSound",1.0f,"StartTiming");         PlaySoundAtEntity("","walkandgrunt.snt","Player",0,false);     }     if(x=="5") {         Addtimer("RandomSound",1.0f,"StartTiming");         PlaySoundAtEntity("","walkandgrunt.snt","Player",0,false);     } }
  void DoorCheck(string &in asTimer) { if(GetGlobalVarInt("Globalvar1") == 1)     {         SetSwingDoorLocked("elevator_door_1", false, false);         RemoveTimer("GlobalCheck");     } else { AddTimer("GlobalCheck", 0, "DoorCheck"); } } 
 
 
I get signature matching errors at the AddTimer parts. If there's an simplier way then please go ahead and suggest.
			  
			
			
 
			
		 |  
	 
 | 
 
	| 12-06-2011, 06:09 AM  | 
	
		
	 | 
 
 
	
		
		Your Computer 
 
 
		
			SCAN ME! 
			
			
			
 
			
	Posts: 3,456 
	Threads: 32 
	Joined: Jul 2011
	
 Reputation: 
235
		
	 | 
	
		
			
RE: Random sound at random time script help 
			 
			
				You have Addtimer in a lot of places where Add Timer should be.
 
Here's a more efficient way of doing what you want, though ( code not tested):
 const string[] sounds_to_play = {     "walkandgrunt.snt",     "walkandgrunt.snt",     "walkandgrunt.snt",     "walkandgrunt.snt",     "walkandgrunt.snt" };
  void OnStart() {     DoorCheck("GlobalCheck");     Addtimer("RandomSound", 1.0f, "SoundTime"); }
  void SoundTime(string &in asTimer) {     int Time = RandInt(0, sounds_to_play.length()-1);     PlaySoundAtEntity("", sounds_to_play[Time], "Player" , 0, false);          // Make sure the minimum range is greater than 0     //    However, it may be more practical to have a number greater than 10     AddTimer(asTimer, RandFloat(1,60), "SoundTime"); }
  void DoorCheck(string &in asTimer) {     if(GetGlobalVarInt("Globalvar1") == 1)     {         SetSwingDoorLocked("elevator_door_1", false, false);         return;     }
      // Never use 0 for time     AddTimer(asTimer, 0.02f, "DoorCheck"); } 
 
  
			 
			
			
 
			
				
(This post was last modified: 12-06-2011, 10:03 AM by Your Computer.)
 
				
			 
		 |  
	 
 | 
 
	| 12-06-2011, 08:27 AM  | 
	
		
	 | 
 
 
	
		
		Gamemakingdude 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 470 
	Threads: 82 
	Joined: Nov 2010
	
 Reputation: 
9
		
	 | 
	
		
			
RE: Random sound at random time script help 
			 
			
				Hi, i have tried this code and i get this error on line 9 it says its missing and ; or ,.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 12-06-2011, 08:55 AM  | 
	
		
	 | 
 
 
	
		
		Your Computer 
 
 
		
			SCAN ME! 
			
			
			
 
			
	Posts: 3,456 
	Threads: 32 
	Joined: Jul 2011
	
 Reputation: 
235
		
	 | 
	
		
			
RE: Random sound at random time script help 
			 
			
				 (12-06-2011, 08:55 AM)Gamemakingdude Wrote:  Hi, i have tried this code and i get this error on line 9 it says its missing and ; or ,. 
Whoops, yeah, the string declaration at the top i forgot to put a ; at the end of it. I have fixed the error in my previous post.
			  
			
			
 
			
		 |  
	 
 | 
 
	| 12-06-2011, 10:04 AM  | 
	
		
	 | 
 
 
	
		
		Gamemakingdude 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 470 
	Threads: 82 
	Joined: Nov 2010
	
 Reputation: 
9
		
	 | 
	
		
			
RE: Random sound at random time script help 
			 
			
				Ok now im getting this no matching signatures to the addtimer on line 12. in the OnStart()
			 
			
			
 
			
		 |  
	 
 | 
 
	| 12-06-2011, 10:59 AM  | 
	
		
	 | 
 
 
	
		
		jens 
 
 
		
			Frictional Games 
			
			
			
 
			
	Posts: 4,093 
	Threads: 199 
	Joined: Apr 2006
	
 Reputation: 
202
		
	 | 
	
		
			
RE: Random sound at random time script help 
			 
			
				change Addtimer to AddTimer on line 12 (that is make the t a capital T).
			 
			
			
			
		 |  
	 
 | 
 
	| 12-06-2011, 11:39 AM  | 
	
		
	 | 
 
 
	 
 |