Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ERR : Unexpected token '{'
Wickedwrath Offline
Junior Member

Posts: 13
Threads: 3
Joined: Oct 2011
Reputation: 0
#1
Question  ERR : Unexpected token '{'

Hello! I finally got my keys and "scary event" to work in my script, but when I added Elven's awesome piano scare-script I'm getting a error "ERR : Unexpected token '{'". Can someone explain what this error means? What I coul'd think of is that I have placed one of those '{ }' wrong, or?
- This is my whole script. Help me solve this, please?

PHP Code: (Select All)
////////////////////////////////////////////////////////////////////////////////////
// Run first time starting map
void OnStart()

///////////////////////////////////////////////////////////////////////////////////
// HUNTED PIANO STARTS PLAYING!

{
AddTimer("pianotimer", 0, "pianotimer");
AddEntityCollideCallback("Player", "pianostop", "pianostop", true, 1);
}

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);
}

///////////////////////////////////////////////////////////////////////////////////
// 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 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!
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");
} 



[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]
(This post was last modified: 10-27-2011, 12:48 AM by Wickedwrath.)
10-20-2011, 05:22 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: ERR : Unexpected token '{'

In your case, you forgot to define a function properly. Do you see the section where it says "ALL THE KEYS!"? The code block below it is just hanging there without a function definition.

Tutorials: From Noob to Pro
10-20-2011, 05:36 PM
Website Find
Wickedwrath Offline
Junior Member

Posts: 13
Threads: 3
Joined: Oct 2011
Reputation: 0
#3
RE: ERR : Unexpected token '{'

(10-20-2011, 05:36 PM)Your Computer Wrote: In your case, you forgot to define a function properly. Do you see the section where it says "ALL THE KEYS!"? The code block below it is just hanging there without a function definition.
I tried to remove it, but it's still not working. Getting the same Error..


[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]
10-20-2011, 05:39 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: ERR : Unexpected token '{'

(10-20-2011, 05:39 PM)Wickedwrath Wrote: I tried to remove it, but it's still not working. Getting the same Error..

What was it that you removed?

Tutorials: From Noob to Pro
10-20-2011, 05:44 PM
Website Find
Wickedwrath Offline
Junior Member

Posts: 13
Threads: 3
Joined: Oct 2011
Reputation: 0
#5
RE: ERR : Unexpected token '{'

(10-20-2011, 05:44 PM)Your Computer Wrote:
(10-20-2011, 05:39 PM)Wickedwrath Wrote: I tried to remove it, but it's still not working. Getting the same Error..

What was it that you removed?
///////////////////////////////////////////////////////////////////////////////////
// ALL THE KEYS!



[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]
10-20-2011, 05:51 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: ERR : Unexpected token '{'

(10-20-2011, 05:51 PM)Wickedwrath Wrote: ///////////////////////////////////////////////////////////////////////////////////
// ALL THE KEYS!

To explain what i said in post #2: A code block is started with a { and ended with a }. The code block below the "ALL THE KEYS!" section implies that you wanted the code block to be part of a function's definition. However, you did not provide the function header. This confused the compiler, who was expecting a function header, but got something else. I only pointed out the commented section to help make it easier for you to find the line where the issue is located. I do not know for what purpose that code block is to be used for, so i'm leaving it to you to define a function header.

Tutorials: From Noob to Pro
10-20-2011, 06:15 PM
Website Find
Wickedwrath Offline
Junior Member

Posts: 13
Threads: 3
Joined: Oct 2011
Reputation: 0
#7
RE: ERR : Unexpected token '{'

Hm, so you are saying that there is something wrong with the Key-part?
It works perfect when I remove the "piano script", so it have to be something wrong with that one, or?

[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]
10-20-2011, 07:01 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#8
RE: ERR : Unexpected token '{'

Yeah, this is the part that is causing the issue:

PHP Code: (Select All)
{
  
AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
  
AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
  
AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
} 

You're going to want it to be something like this:

PHP Code: (Select All)
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);
} 

Tutorials: From Noob to Pro
10-20-2011, 07:10 PM
Website Find
Wickedwrath Offline
Junior Member

Posts: 13
Threads: 3
Joined: Oct 2011
Reputation: 0
#9
RE: ERR : Unexpected token '{'

(10-20-2011, 07:10 PM)Your Computer Wrote: Yeah, this is the part that is causing the issue:

PHP Code: (Select All)
{
  
AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
  
AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
  
AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
} 

You're going to want it to be something like this:

PHP Code: (Select All)
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);
} 
Ah, okay. I did put "void function_name_here(/*parameters here*/)" and the games can load, but the Keys won't work now.. I don't get this at all. Also, the Piano doesn't work either.


[Image: tumblr_lfv1jh0Z5V1qfw81zo1_500.gif]
10-20-2011, 07:32 PM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#10
RE: ERR : Unexpected token '{'

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
10-20-2011, 07:48 PM
Website Find




Users browsing this thread: 1 Guest(s)