| 
		
	
		| Wickedwrath   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Oct 2011
 Reputation: 
0
 | 
			| RE: ERR : Unexpected token '{' 
 
				 (10-20-2011, 07:48 PM)jens Wrote:  You'll need some scripting/programing understanding, you are just jumping right in with no understanding of the basics. Perhaps reading this is a good starting place, http://wiki.frictionalgames.com/hpl2/tut...t_beginner I did read on that link, jens, and I'm trying to understand what things are. But what exactly do I have to write on this one: 
 void function_name_here(/*parameters here*/){
 AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
 AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
 }
 
I have tryed everything, like: void UseKeyOnDoor/UsedKeyOnLockedDoor, etc. But they still are locked..
			 
 |  |  
	| 10-20-2011, 09:36 PM |  |  
	
		| jens   Frictional Games
 
 Posts: 4,093
 Threads: 199
 Joined: Apr 2006
 Reputation: 
202
 | 
			| RE: ERR : Unexpected token '{' 
 
				You are probably looking to have the script like this, but chances are it does not work. ////////////////////////////////////////////////////////////////////////////////////// Run first time starting map
 void OnStart()
 {
 ///////////////////////////////////////////////////////////////////////////////////
 // HUNTED PIANO STARTS PLAYING!
 AddTimer("pianotimer", 0, "pianotimer");
 AddEntityCollideCallback("Player", "pianostop", "pianostop", true, 1);
 
 ///////////////////////////////////////////////////////////////////////////////////
 // ALL THE KEYS!
 AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
 AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
 }
 
 void PianoTimer(string &in asTimer)
 {
 PlaySoundAtEntity("piano", "general_piano03.ogg", "Piano", 0, false);
 AddTimer("pianotimer", 18, "pianotimer");
 }
 
 void pianostop(string &in asEntity, int alState)
 {
 StopSound("piano", 0);
 RemoveTimer("pianotimer");
 SetLeverStuckState("piano", 0, true);
 AddPropImpulse("piano", 0, 0, 100, "world");
 PlaySoundAtEntity("piano", "impact_wood_heavy_med3", "Piano", 0, false);
 CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "impact", false);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_1", 0, false);
 RemoveItem("Key_1");
 }
 
 void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_2", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_2", 0,false);
 RemoveItem("Key_2");
 }
 
 void Message_1(string &in asEntity)
 {
 SetMessage("Message", "Message_1", 2);
 }
 
 void UsedKeyOnDoor_3(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("metal_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
 RemoveItem("Secretkey2");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
 // SCARY DOOR/CHAIR EVENT IN CORRIDOOR! - OnEnter is ran every time you enter a map.
 void OnEnter()
 {
 StopSound("Sound_1", 0);
 //COLLIDES
 AddEntityCollideCallback("Player", "Event_Start_Collide_Area", "StartEvent", true, 1);
 }
 
 void StartEvent(string &in asParent, string &in asChild, int alState)
 {
 CreateParticleSystemAtEntityExt("awedsasf", "ps_dust_push_15.ps", "Particle_Spawn",
 false, 1.0f, 0.1f, 0.1f, 1,
 false, 1, 1, 1, 1
 );
 
 AddTimer("asdtgeqtfgd", 1.0f, "LoopyTimerCounting");
 }
 
 void LoopyTimerCounting(string &in asTimer)
 {
 AddLocalVarInt("Stage", 1);
 float fEventSpeed = 0.0f;
 
 switch(GetLocalVarInt("Stage"))
 {
 case 1:
 SetSwingDoorClosed("WindDoor", true, true);
 SetSwingDoorDisableAutoClose("WindDoor", false);
 AddPropForce("WindDoor", 0, 0, 290.0f, "world");
 SetSwingDoorLocked("WindDoor", true, true);
 FadeInSound("Sound_1", 1.0f, true);
 FadeLightTo("PointLight_1", 0.8f, 1, 0, 0, 0, 0.3);
 break;
 
 case 2:
 AddPropForce("chandelier_simple_short_6", 0, 0, 100.0f, "world");
 fEventSpeed = 0.5f;
 FadeLightTo("PointLight_1", 0, 0, 0, 0, 0, 0.5);
 FadeLightTo("PointLight_2", 0.7f, 1, 0, 0, 0, 0.6);
 break;
 
 case 3:
 AddPropForce("chandelier_simple_short_6", 0, 0, 2400.0f, "world");
 fEventSpeed = 0.6f;
 FadeLightTo("PointLight_2", 0, 0, 0, 0, 0, 0.6);
 FadeLightTo("PointLight_3", 0.5f, 1, 0, 0, 0, 0.6);
 break;
 
 case 4:
 SetEntityActive("block_box_nonchar_1", true);
 AddPropForce("chair_wood02_4", 0, 0, 0, "world");
 fEventSpeed = 0.0f;
 FadeLightTo("PointLight_3", 0, 0, 0, 0, 0, 0.5);
 break;
 
 case 5:
 AddPropForce("chair_wood02_4",4000, 600, 0, "world");
 fEventSpeed = 0.0f;
 break;
 
 case 6:
 SetEntityActive("block_box_nonchar_1", false);
 break;
 }
 
 if(GetLocalVarInt("Stage") < 10)
 AddTimer("thisloopsthetimer", fEventSpeed, "LoopyTimerCounting");
 }
 
 |  |  
	| 10-21-2011, 07:27 AM |  |  
	
		| Wickedwrath   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Oct 2011
 Reputation: 
0
 | 
			| RE: ERR : Unexpected token '{' 
 
				 (10-21-2011, 07:27 AM)jens Wrote:  You are probably looking to have the script like this, but chances are it does not work.
 ////////////////////////////////////////////////////////////////////////////////////// Run first time starting map
 void OnStart()
 {
 ///////////////////////////////////////////////////////////////////////////////////
 // HUNTED PIANO STARTS PLAYING!
 AddTimer("pianotimer", 0, "pianotimer");
 AddEntityCollideCallback("Player", "pianostop", "pianostop", true, 1);
 
 ///////////////////////////////////////////////////////////////////////////////////
 // ALL THE KEYS!
 AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
 AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
 AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
 }
 
 void PianoTimer(string &in asTimer)
 {
 PlaySoundAtEntity("piano", "general_piano03.ogg", "Piano", 0, false);
 AddTimer("pianotimer", 18, "pianotimer");
 }
 
 void pianostop(string &in asEntity, int alState)
 {
 StopSound("piano", 0);
 RemoveTimer("pianotimer");
 SetLeverStuckState("piano", 0, true);
 AddPropImpulse("piano", 0, 0, 100, "world");
 PlaySoundAtEntity("piano", "impact_wood_heavy_med3", "Piano", 0, false);
 CreateParticleSystemAtEntity("", "ptest_dust_falling.ps", "impact", false);
 }
 
 void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_1", 0, false);
 RemoveItem("Key_1");
 }
 
 void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_2", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_2", 0,false);
 RemoveItem("Key_2");
 }
 
 void Message_1(string &in asEntity)
 {
 SetMessage("Message", "Message_1", 2);
 }
 
 void UsedKeyOnDoor_3(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("metal_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
 RemoveItem("Secretkey2");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
 // SCARY DOOR/CHAIR EVENT IN CORRIDOOR! - OnEnter is ran every time you enter a map.
 void OnEnter()
 {
 StopSound("Sound_1", 0);
 //COLLIDES
 AddEntityCollideCallback("Player", "Event_Start_Collide_Area", "StartEvent", true, 1);
 }
 
 void StartEvent(string &in asParent, string &in asChild, int alState)
 {
 CreateParticleSystemAtEntityExt("awedsasf", "ps_dust_push_15.ps", "Particle_Spawn",
 false, 1.0f, 0.1f, 0.1f, 1,
 false, 1, 1, 1, 1
 );
 
 AddTimer("asdtgeqtfgd", 1.0f, "LoopyTimerCounting");
 }
 
 void LoopyTimerCounting(string &in asTimer)
 {
 AddLocalVarInt("Stage", 1);
 float fEventSpeed = 0.0f;
 
 switch(GetLocalVarInt("Stage"))
 {
 case 1:
 SetSwingDoorClosed("WindDoor", true, true);
 SetSwingDoorDisableAutoClose("WindDoor", false);
 AddPropForce("WindDoor", 0, 0, 290.0f, "world");
 SetSwingDoorLocked("WindDoor", true, true);
 FadeInSound("Sound_1", 1.0f, true);
 FadeLightTo("PointLight_1", 0.8f, 1, 0, 0, 0, 0.3);
 break;
 
 case 2:
 AddPropForce("chandelier_simple_short_6", 0, 0, 100.0f, "world");
 fEventSpeed = 0.5f;
 FadeLightTo("PointLight_1", 0, 0, 0, 0, 0, 0.5);
 FadeLightTo("PointLight_2", 0.7f, 1, 0, 0, 0, 0.6);
 break;
 
 case 3:
 AddPropForce("chandelier_simple_short_6", 0, 0, 2400.0f, "world");
 fEventSpeed = 0.6f;
 FadeLightTo("PointLight_2", 0, 0, 0, 0, 0, 0.6);
 FadeLightTo("PointLight_3", 0.5f, 1, 0, 0, 0, 0.6);
 break;
 
 case 4:
 SetEntityActive("block_box_nonchar_1", true);
 AddPropForce("chair_wood02_4", 0, 0, 0, "world");
 fEventSpeed = 0.0f;
 FadeLightTo("PointLight_3", 0, 0, 0, 0, 0, 0.5);
 break;
 
 case 5:
 AddPropForce("chair_wood02_4",4000, 600, 0, "world");
 fEventSpeed = 0.0f;
 break;
 
 case 6:
 SetEntityActive("block_box_nonchar_1", false);
 break;
 }
 
 if(GetLocalVarInt("Stage") < 10)
 AddTimer("thisloopsthetimer", fEventSpeed, "LoopyTimerCounting");
 }
 
 Everything worked, exept the piano-script, and I like how you organized it. It's easy to read, and thats important. I got everything to work with this one, but I prefer how your set up. So, any ideas what the problem is with the piano?
 /////////////////////////////////// Run first time starting map
 void OnStart()
 {
 AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor_1", true);
 AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
 AddUseItemCallback("", "Key_3", "Door_3", "UsedKeyOnDoor_3", true);
 AddTimer("pianotimer", 0, "pianotimer");
 AddEntityCollideCallback("Player", "pianostop", "pianostop", true, 1);
 StopSound("Sound_1", 0);
 //COLLIDES
 AddEntityCollideCallback("Player", "Event_Start_Collide_Area", "StartEvent", true, 1);
 }
 
 ///////////////////
 // HUNTED PIANO //
 /* A hunted piano starts playing and scares the player
 */
 
 void pianotimer(string &in asTimer)
 {
 PlaySoundAtEntity("piano", "general_piano01", "Piano", 0, false);
 AddTimer("pianotimer", 18, "pianotimer");
 }
 
 void pianostop(string &in asParent, string &in asChild, int alState)
 {
 StopSound("piano", 0);
 RemoveTimer("pianotimer");
 SetLeverStuckState("piano", -1, true);
 AddPropImpulse("piano", 0, 0, 100, "World");
 PlaySoundAtEntity("piano", "break_wood", "Piano", 0, false);
 CreateParticleSystemAtEntity("", "ps_impact_dirt_high.ps", "impact", false);
 }
 
 //END HUNTING PIANO//
 ////////////////////
 
 ///////////////
 // ALL KEYS //
 
 void UsedKeyOnDoor_1(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_1", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_1", 0, false);
 RemoveItem("Key_1");
 }
 
 void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_2", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_2", 0,false);
 RemoveItem("Key_2");
 }
 
 void Message_1(string &in asEntity)
 {
 SetMessage("Message", "Message_1", 2);
 }
 
 void UsedKeyOnDoor_3(string &in asItem, string &in asEntity)
 {
 SetSwingDoorLocked("Door_3", false, true);
 PlaySoundAtEntity("", "unlock_door", "Door_3", 0, false);
 RemoveItem("Key_3");
 }
 //END ALL KEYS//
 ////////////////
 
 ///////////////////////////////
 // SCARY EVENT IN CORRIDOOR //
 /* Some strange wind are coming and smashes the door and locking it + a chair moves
 */
 void OnEnter()
 {
 
 }
 void StartEvent(string &in asParent, string &in asChild, int alState)
 {
 CreateParticleSystemAtEntityExt("awedsasf", "ps_dust_push_15.ps", "Particle_Spawn", false, 1.0f, 0.1f, 0.1f, 1, false, 1, 1, 1, 1);
 AddTimer("asdtgeqtfgd", 1.0f, "LoopyTimerCounting");
 }
 
 void LoopyTimerCounting(string &in asTimer)
 {
 AddLocalVarInt("Stage", 1);
 float fEventSpeed = 0.0f;
 switch(GetLocalVarInt("Stage"))
 {case 1:
 SetSwingDoorClosed("WindDoor", true, true);
 SetSwingDoorDisableAutoClose("WindDoor", false);
 AddPropForce("WindDoor", 0, 0, 290.0f, "world");
 SetSwingDoorLocked("WindDoor", true, true);
 
 FadeInSound("Sound_1", 1.0f, true);
 FadeLightTo("PointLight_1", 0.8f, 1, 0, 0, 0, 0.3);
 break;
 
 case 2:
 AddPropForce("chandelier_simple_short_6", 0, 0, 100.0f, "world");
 fEventSpeed = 0.5f;
 FadeLightTo("PointLight_1", 0, 0, 0, 0, 0, 0.5);
 FadeLightTo("PointLight_2", 0.7f, 1, 0, 0, 0, 0.6);
 break;
 
 case 3:
 AddPropForce("chandelier_simple_short_6", 0, 0, 2400.0f, "world");
 fEventSpeed = 0.6f;
 FadeLightTo("PointLight_2", 0, 0, 0, 0, 0, 0.6);
 FadeLightTo("PointLight_3", 0.5f, 1, 0, 0, 0, 0.6);
 break;
 
 case 4:
 SetEntityActive("block_box_nonchar_1", true);
 AddPropForce("chair_wood02_4", 0, 0, 0, "world");
 fEventSpeed = 0.0f;
 FadeLightTo("PointLight_3", 0, 0, 0, 0, 0, 0.5);
 break;
 case 5:
 
 AddPropForce("chair_wood02_4",4000, 600, 0, "world");
 fEventSpeed = 0.0f;
 break;
 case 6:
 
 SetEntityActive("block_box_nonchar_1", false);
 break;
 }
 if(GetLocalVarInt("Stage") < 10)
 {
 AddTimer("thisloopsthetimer", fEventSpeed, "LoopyTimerCounting");
 }
 }
 
 //END SCARY EVENT IN CORRIDOOR//
 ///////////////////////////////
 
 
  ![[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]](http://30.media.tumblr.com/tumblr_lfv1jh0Z5V1qfw81zo1_500.gif)  |  |  
	| 10-21-2011, 07:41 AM |  |  
	
		| Homicide13   Senior Member
 
 Posts: 323
 Threads: 41
 Joined: Nov 2010
 Reputation: 
14
 | 
			| RE: ERR : Unexpected token '{' 
 
				Is the name of the piano in the world editor "Piano"? I believe it defaults to "piano_01" when you first place it.
 
 
				
(This post was last modified: 10-21-2011, 08:14 PM by Homicide13.)
 |  |  
	| 10-21-2011, 08:13 PM |  |  
	
		| Wickedwrath   Junior Member
 
 Posts: 13
 Threads: 3
 Joined: Oct 2011
 Reputation: 
0
 | 
			| RE: ERR : Unexpected token '{' 
 
				 (10-21-2011, 08:13 PM)Homicide13 Wrote:  Is the name of the piano in the world editor "Piano"? I believe it defaults to "piano_01" when you first place it. Well, Yea. I Rename it and that really doesen't matter, since you can change the name in the editor and have the same name in the script. Any clue what the reason could be, why the piano don't work?
			 
 |  |  
	| 10-26-2011, 10:34 PM |  |  |