Frictional Games Forum (read-only)

Full Version: ERR : unexpected token '{'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Yes I know there are other threads with this same problem. But I don't get how they were able to fix theirs. So telling me what i'm doing wrong and telling me how to fix it would be nice(This is my first script BTW)

Here it is, nice and short.

void onStart ()
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackfunc("key_1","OnPickup");
}

void UsedKeyOnDoor(string &in asItem, string &asEntity);
{
SetSwingDoorLocked("locked_door1",false,true);
PlaySoundAtEntity("","unlock_door.snt","locked_door1",0,false);
RemoveItem("key_1");
}

void onLeave ()
{
}
it should be

OnStart()

OnEnter()

OnLeave()

not onStart etc
In addition to what Silent said, this line is incorrect:

void UsedKeyOnDoor(string &in asItem, string &asEntity);


Any line that starts with "void" does not need a semicolon ";" on the end. It should be:

void UsedKeyOnDoor(string &in asItem, string &asEntity)


Hope that helped.
Thanks Big Grin no more script errors, but my door still won't open >.>
Doh. Try revising the syntax of "UsedKeyOnDoor" from (string &in asItem, string &asEntity) to
:


(string &in asItem, string &in asEntity)



Also, where is the function "OnPickup"? You have a callback for it, but no function.
anyone who could help me with this one ? error is at main(6,1) "unexpected token" '{' have tried for hours to find it
void OnStart()
{
AddUseItemCallback("", "Awesomekey_1", "doorone", "KeyOnDoor", true);
}
void Keyondoor(string &in asItem, string &in asEntity);
{
SetSwingDoorLocked("doorone", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "doorone", 0, false)
RemoveItem("Awesomekey_1");
}
////////////////////////////
// Run when entering map
void OnEnter ()
{
}
////////////////////////////
// Run when leaving map
void OnLeave ()
{
}
(07-12-2012, 03:26 AM)CookieMonster Wrote: [ -> ]anyone who could help me with this one ? error is at main(6,1) "unexpected token" '{' have tried for hours to find it

You've made the same mistake as the topic starter with the semicolon. You're also missing a semicolon for PlaySoundAtEntity.
thank you, i've been blind not to see that
But the door won't open now, anyone who know why ? Smile
(yes, i'm new to this)
nevermind, i figured it out Smile
Thanks! I ragequited so I havnt touched the game for a week lol.....

You will probably see more of my idiotic posts for help XD