Shoop 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 36 
	Threads: 10 
	Joined: Feb 2011
	
 Reputation: 
0
		
	 | 
	
		
			
  
Script Crashes Custom Story -SOLVED- 
			 
			
				//////////////////////////// 
// Run first time starting map 
void OnStart() 
{    
   AddUseItemCallback("", "key1", "castle_1", "UsedKeyOnDoor", true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
    SetSwingDoorLocked("castle_1", false, true); 
    PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false); 
    RemoveItem("key1"); 
} 
    AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor", true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
    SetSwingDoorLocked("metal_1", false, true); 
    PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false); 
    RemoveItem("key2"); 
} 
//////////////////////////// 
// Run when entering map 
void OnEnter() 
{ 
  
} 
  
//////////////////////////// 
// Run when leaving map 
void OnLeave() 
{ 
  
}
 It is just a quick and simple one, but I have two keys for two different doors in this script. Why does it crash when I start, I probably did something wrong right? It does say something about the script when it crashes. 
Thanks.
			  
			
			
			
				
(This post was last modified: 04-01-2011, 08:11 PM by Shoop.)
 
				
			 
		 |  
	 
 | 
 
	| 04-01-2011, 06:45 PM  | 
	
		
	 | 
 
 
	
		
		MrBigzy 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 616 
	Threads: 18 
	Joined: Mar 2011
	
 Reputation: 
8
		
	 | 
	
		
			
RE: Script Crashes Custom Story? 
			 
			
				Before the AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor", true); there's an extra bracket, take it out. You also put two functions with the same name...that's a nono.
			 
			
			
			
		 |  
	 
 | 
 
	| 04-01-2011, 06:51 PM  | 
	
		
	 | 
 
 
	
		
		Shoop 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 36 
	Threads: 10 
	Joined: Feb 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Script Crashes Custom Story? 
			 
			
				 (04-01-2011, 06:51 PM)MrBigzy Wrote:  Before the AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor", true); there's an extra bracket, take it out. You also put two functions with the same name...that's a nono. 
How would I fix the function part? I see by added 2 to the end doesn't work. Sorry I am very new to this.
			  
			
			
			
				
(This post was last modified: 04-01-2011, 07:54 PM by Shoop.)
 
				
			 
		 |  
	 
 | 
 
	| 04-01-2011, 07:02 PM  | 
	
		
	 | 
 
 
	
		
		MrBigzy 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 616 
	Threads: 18 
	Joined: Mar 2011
	
 Reputation: 
8
		
	 | 
	
		
			
RE: Script Crashes Custom Story? 
			 
			
				It will work, just make sure you add it in the function as well as putting AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor2, true); 
so you gotta make sure that it's calling the right function.
			 
			
			
			
		 |  
	 
 | 
 
	| 04-01-2011, 08:02 PM  | 
	
		
	 | 
 
 
	
		
		Linus Ågren 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 309 
	Threads: 58 
	Joined: Jan 2011
	
 Reputation: 
5
		
	 | 
	
		
			
RE: Script Crashes Custom Story? 
			 
			
				void OnStart() 
{   
   AddUseItemCallback("", "key1", "castle_1", "UsedKeyOnDoor", true); 
   AddUseItemCallback("", "key2", "metal_1", "UsedKeyOnDoor2", true); 
} 
 
void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
{ 
    SetSwingDoorLocked("castle_1", false, true); 
    PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false); 
    RemoveItem("key1"); 
} 
 
void UsedKeyOnDoor2(string &in asItem, string &in asEntity) 
{ 
    SetSwingDoorLocked("metal_1", false, true); 
    PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false); 
    RemoveItem("key2"); 
} 
//////////////////////////// 
// Run when entering map 
void OnEnter() 
{ 
 
} 
 
//////////////////////////// 
// Run when leaving map 
void OnLeave() 
{ 
 
} 
 
Try that.
			 
			
			
 
Creator of The Dark Treasure. 
			
		 |  
	 
 | 
 
	| 04-01-2011, 08:02 PM  | 
	
		
	 | 
 
 
	
		
		Shoop 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 36 
	Threads: 10 
	Joined: Feb 2011
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Script Crashes Custom Story? 
			 
			
				Thank you Junkfood for writing it out for me, and you too Bigzy.
			 
			
			
			
		 |  
	 
 | 
 
	| 04-01-2011, 08:10 PM  | 
	
		
	 | 
 
 
	 
 |