| 
		
	
		| JonnyAnomaly   Member
 
 Posts: 179
 Threads: 20
 Joined: Nov 2012
 Reputation: 
14
 | 
			|  Scripting problem 
 
				I'm trying to make a script to make an enemy randomly appear and disappear, then loop the script. The problem is, after he has been activated once, he never comes back. Here is my script at the moment -
 void OnEnter()
 {
 AddEntityCollideCallback("Player", "ScriptArea_1", "activatemonster1", true, 1);
 }
 
 void activatemonster1(string &in asParent, string &in asChild, int alState)
 {
 SetEntityActive("manhunter_1", true);
 AddTimer("", RandFloat(5.0f, 20.0), "deactivatemonster1");
 }
 
 void deactivatemonster1(string &in asParent, string &in asChild, int alState)
 {
 SetEntityActive("manhunter_1", false);
 AddTimer("", RandFloat(60.0f, 120.0), "activatemonster1");
 }
 
 Would someone be able to tell me why its not repeating itself?
 |  |  
	| 08-01-2013, 01:00 PM |  |  
	
		| PutraenusAlivius   Posting Freak
 
 Posts: 4,713
 Threads: 75
 Joined: Dec 2012
 Reputation: 
119
 | 
			| RE: Scripting problem 
 
				void OnEnter(){
 AddEntityCollideCallback("Player", "ScriptArea_1", "activatemonster1", true, 1);
 }
 
 void activatemonster1(string &in asParent, string &in asChild, int alState)
 {
 SetEntityActive("manhunter_1", true);
 AddTimer("", RandFloat(5.0f, 20.0), "deactivatemonster1");
 }
 
 void deactivatemonster1(string &in asTimer)
 {
 SetEntityActive("manhunter_1", false);
 AddTimer("", RandFloat(60.0f, 120.0), "activatemonster1");
 }
 
 You had the wrong callback syntax in the first AddTimer call.
 
 "Veni, vidi, vici.""I came, I saw, I conquered."
 |  |  
	| 08-01-2013, 01:06 PM |  |  
	
		| JonnyAnomaly   Member
 
 Posts: 179
 Threads: 20
 Joined: Nov 2012
 Reputation: 
14
 | 
			| RE: Scripting problem 
 
				Ah I see, thanks for your help!
			 |  |  
	| 08-01-2013, 01:44 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Scripting problem 
 
				void OnEnter() // should probably be OnStart{
 AddEntityCollideCallback("Player", "ScriptArea_1", "ActivateMonster", true, 1);
 }
 
 void ActivateMonster(string &in asParent, string &in asChild, int alState)
 {
 if (asChild == "ScriptArea_1")
 ActivateMonster("manhunter_1");
 }
 
 void ActivateMonster(string &in monster)
 {
 ResetProp(monster);
 SetEntityActive(monster, true);
 AddTimer(monster, RandFloat(5.0f, 20.0), "DeactivateMonster");
 }
 
 void DeactivateMonster(string &in monster)
 {
 SetEntityActive(monster, false);
 AddTimer(monster, RandFloat(60.0f, 120.0), "ActivateMonster");
 }
 
 
 
				
(This post was last modified: 08-01-2013, 05:20 PM by Your Computer.)
 |  |  
	| 08-01-2013, 05:19 PM |  |  
	
		| JonnyAnomaly   Member
 
 Posts: 179
 Threads: 20
 Joined: Nov 2012
 Reputation: 
14
 | 
			| RE: Scripting problem 
 
				Thanks, I'm still trying to learn the basics of scripting, so many stupid mistakes are made. I'm still at the stage where I punch the air if my map loads without a fatal error.
			 
				
(This post was last modified: 08-01-2013, 05:43 PM by JonnyAnomaly.)
 |  |  
	| 08-01-2013, 05:39 PM |  |  
	
		| DeAngelo   Senior Member
 
 Posts: 263
 Threads: 26
 Joined: Feb 2013
 Reputation: 
11
 | 
			| RE: Scripting problem 
 
				As a scripter you'll have to walk the fine balance of figuring things out yourself so you get better, and asking the fine folk here. My general rule of thumb: don't ask until the error is causing you to re-evaluate your goals in life.
			 
 |  |  
	| 08-01-2013, 11:37 PM |  |  |