| 
		
	
		| jtylerg   Junior Member
 
 Posts: 4
 Threads: 2
 Joined: Aug 2012
 Reputation: 
0
 | 
			| Fatal Error on this script 
 
				All that is on this script is 2 keys which open 2 different doors (Basementkey_1, which opens mansion_1... and startkey, which opens cabinet_1) when i go to start the game it crashes with a fatal error saying "main 15,1 : ERR Unexpected Token '{' 
Any fixes or ideas of why this happens? (the code starts on line 1, it's just messed up on here for some reason... also, before i added startkey and cabinet_1 codes... Basementkey_1 and mansion_1 worked perfectly fine)
 
////////////////////////////// Run when entering mapvoid OnStart(){AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);}void UsedKeyOnDoor(string &in asItem, string &in asEntity){SetSwingDoorLocked("mansion_1", false, true);PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);RemoveItem("BasementKey_1");}{AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);}void UsedKeyOnDoor(string &in asItem, string &in asEntity){SetSwingDoorLocked("cabinet_1", false, true);PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);RemoveItem("startkey");}////////////////////////////// Run when leaving mapvoid OnLeave(){} |  |  
	| 08-15-2012, 04:07 PM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Fatal Error on this script 
 
				You must put all callbacks under void OnStart(), you can use void OnEnter() but that has more specific applications. You also can't have two functions with the exact same name (you used UseKeyOnDoor twice). Here's a cool trick you can do using asItem and asEntity that will fix your problem as well as reduce script clutter:
 
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked(asEntity, false, false);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
 
 Hope that helped
 
 I rate it 3 memes. |  |  
	| 08-15-2012, 04:19 PM |  |  
	
		| Ongka   Member
 
 Posts: 225
 Threads: 3
 Joined: Nov 2010
 Reputation: 
20
 | 
			| RE: Fatal Error on this script 
 
				////////////////////////////// Run when entering map
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
 }
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
 RemoveItem("BasementKey_1");
 }
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("cabinet_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
 RemoveItem("startkey");
 }
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 }
 
 
 
 You put brackets around the green function but didn't use a header, this caused the error.
 You can just put it in the voidOnStart().
 
 Edit: Andy was a bit faster ^^
 
 
				
(This post was last modified: 08-15-2012, 04:20 PM by Ongka.)
 |  |  
	| 08-15-2012, 04:19 PM |  |  
	
		| jtylerg   Junior Member
 
 Posts: 4
 Threads: 2
 Joined: Aug 2012
 Reputation: 
0
 | 
			| RE: Fatal Error on this script 
 
				I copy and pasted Ongka's solution onto notepad++ ad still recieve a fatal error at 15'1 unexpected token { 
  (08-15-2012, 04:19 PM)Ongka Wrote:  ////////////////////////////// Run when entering map
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
 }
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
 RemoveItem("BasementKey_1");
 }
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("cabinet_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
 RemoveItem("startkey");
 }
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 }
 
 
 
 You put brackets around the green function but didn't use a header, this caused the error.
 You can just put it in the voidOnStart().
 
 Edit: Andy was a bit faster ^^
 I copy and pasted that and still receive the same error.
 
  (08-15-2012, 04:19 PM)andyrockin123 Wrote:  You must put all callbacks under void OnStart(), you can use void OnEnter() but that has more specific applications. You also can't have two functions with the exact same name (you used UseKeyOnDoor twice). Here's a cool trick you can do using asItem and asEntity that will fix your problem as well as reduce script clutter:
 
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked(asEntity, false, false);
 PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
 RemoveItem(asItem);
 }
 
 
 Hope that helped
 This doesn't work either... same error every time "15,1" Unexpected token {
			
				
(This post was last modified: 08-16-2012, 06:48 PM by jtylerg.)
 |  |  
	| 08-16-2012, 06:44 PM |  |  
	
		| Ongka   Member
 
 Posts: 225
 Threads: 3
 Joined: Nov 2010
 Reputation: 
20
 | 
			| RE: Fatal Error on this script 
 
				////////////////////////////// Run when entering map
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnCabinet", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
 RemoveItem("BasementKey_1");
 }
 
 void UsedKeyOnCabinet(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("cabinet_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
 RemoveItem("startkey");
 }
 
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 }
 
 Changed the function name, this should work.
 
 
				
(This post was last modified: 08-16-2012, 07:01 PM by Ongka.)
 |  |  
	| 08-16-2012, 07:00 PM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Fatal Error on this script 
 
				Considering my revision isn't even 15 characters long, I'm almost completely sure you didn't clear/delete your script original before pasting mine in. This concept would also explain why regardless of our solutions, you get the same exact error.
			 
 I rate it 3 memes. |  |  
	| 08-16-2012, 07:16 PM |  |  
	
		| TheGreatCthulhu   Member
 
 Posts: 213
 Threads: 10
 Joined: Oct 2010
 Reputation: 
32
 | 
			| RE: Fatal Error on this script 
 
				True. Also make sure to go to the line that caused the error and inspect the code yourselfThe error comes from an "orphaned" method body (the stuff beteen { and } )
 Bellow is your original code - the reason for the error is in red:
 
 ////////////////////////////
 // Run when entering map
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
 RemoveItem("BasementKey_1");
 }
 {
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("cabinet_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
 RemoveItem("startkey");
 }
 
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 }
 
 You have to take the AddUseItemCallback(...) call out of there, and delete the invalid {} block.
 |  |  
	| 08-16-2012, 07:21 PM |  |  
	
		| jtylerg   Junior Member
 
 Posts: 4
 Threads: 2
 Joined: Aug 2012
 Reputation: 
0
 | 
			| RE: Fatal Error on this script 
 
				 (08-16-2012, 07:00 PM)Ongka Wrote:  ////////////////////////////// Run when entering map
 void OnStart()
 {
 AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnCabinet", true);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("mansion_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
 RemoveItem("BasementKey_1");
 }
 
 void UsedKeyOnCabinet(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("cabinet_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
 RemoveItem("startkey");
 }
 
 ////////////////////////////
 // Run when leaving map
 void OnLeave()
 {
 }
 
 Changed the function name, this should work.
 Thanks! That worked perfectly
			 |  |  
	| 08-16-2012, 08:44 PM |  |  |