Frictional Games Forum (read-only)

Full Version: Expcected Error help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there, I have made my first custom story, the map is working fine. I have a line of commands for a key and door which worked at first, now i have added a jumpscare which i have seen in a tutorial on youtube. It crashes immediatly and says: main 14,19 EXPECTED IDENTIFIER. I can also give a screenshot of the code in notepad ++, private message me.

My codes are:
PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""Teleport_Script_1""jumpscare"true1);
}

void jumpscare(string &in asParentstring &in asChildint alStates)

{
    
SetEntityActive("corpse_male_3"true);
    
AddPropForce("corpse_male_3"00100"world");
}


AddUseItemCallback(" ""key_tower_1""castle_1""KeyOnDoor"true); 

void KeyOnDoor(string &in asItemstring &in asEntity)

{
SetSwingDoorLocked("castle_1"falsetrue);
PlaySoundAtEntity("""unlock_door""castle_1"0false);
RemoveItem("key_tower_1");


void OnStart()
{
AddEntityCollideCallback("Player""Teleport_Script_1""jumpscare"true1);
}

void jumpscare(string &in asParentstring &in asChildint alStates)

{
    
SetEntityActive("corpse_male_3"true);
    
AddPropForce("corpse_male_3"00100"world");


Is there anyone who understands the scripting better than me and can help me out? Thank you!!!
First off, you can only have 1 script block with the same name (for example OnStart). Having multiple will cause a crash. If you need more script inside your OnStart block, just add it all inside the same one.

For example:
Code:
void OnStart()
{
    code1();
    code2();
}

Secondly, you can not have a callback script outside a block. This line:

Code:
AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

is located between 2 blocks, therefore causing a crash as well. You want to move this within your OnStart block.

Try that and tell me how it goes. I'll assist further if you need more help (that is, if I can cause I'm about to go to bed. If I can't, there are many others here).
(02-14-2014, 01:14 AM)Mudbill Wrote: [ -> ]First off, you can only have 1 script block with the same name (for example OnStart). Having multiple will cause a crash. If you need more script inside your OnStart block, just add it all inside the same one.

For example:
Code:
void OnStart()
{
    code1();
    code2();
}

Secondly, you can not have a callback script outside a block. This line:

Code:
AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

is located between 2 blocks, therefore causing a crash as well. You want to move this within your OnStart block.

Try that and tell me how it goes. I'll assist further if you need more help (that is, if I can cause I'm about to go to bed. If I can't, there are many others here).



Thanks a lot! I have learned way more from scripting since i started a few weeks ago. I also use Geany now instead of Notepad++. A guy on youtube called ThisIsYourComputer has a good tutorial on how to set up geany for amnesia scripting.
ThisIsYourComputer xD
Yeap, it's YourComputer, he's been off since 10-31-2013 (last visit)
I wonder what happened to him?
31/10/2013 was halloween... :o
I'm not saying it was aliens, but... Aliens.
Look at what you type:
void OnStart()
{
AddEntityCollideCallback("Player", "Teleport_Script_1", "jumpscare", true, 1);
}

void jumpscare(string &in asParent, string &in asChild, int alStates)

{
SetEntityActive("corpse_male_3", true);
AddPropForce("corpse_male_3", 0, 0, 100, "world");
}


AddUseItemCallback(" ", "key_tower_1", "castle_1", "KeyOnDoor", true);

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

{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("key_tower_1");
}

but it might be:
void OnStart()
{
AddEntityCollideCallback("Player", "Teleport_Script_1", "jumpscare", true, 1);
}
void jumpscare(string &in asParent, string &in asChild, int alState)

{
SetEntityActive("corpse_male_3", true);
AddPropForce("corpse_male_3", 0, 0, 100, "world");
}
Errors: 2 voids OnStart()
else:
void jumpscares(string &in asParent, string &in asChild, int alState)