Frictional Games Forum (read-only)

Full Version: Script Fatal Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi everyone. I am new at forum and my english is not very good really, so i need help about my script. My script in .hps file is
void OnStart()
{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("TheKey_1");
}



{
AddEntityCollideCallback("Player", "The_Quest_Area", "GetTheQuest", true, 1);
AddEntityCollideCallback("Player", "The_Complete_Area", "FinishTheQuest", true, 1);
}

void GetTheQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("thequest", "TheQuest");
}

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("thequest", "TheQuest");
}
I am getting the Fatal error when i try to enter my custom story. The error is; FATAL ERROR:Could not load script file custom_stories/bla/maps/bla.hps!
main(15,1):ERR:Unexpected '{'
Thanks for your help,
{
AddEntityCollideCallback("Player", "The_Quest_Area", "GetTheQuest", true, 1);
AddEntityCollideCallback("Player", "The_Complete_Area", "FinishTheQuest", true, 1);
}


it has nothing to trigger it. no void coming before it. Its just kind of ... there. try putting it in the brackets under void onstart, unless of course you only want it to happen if UsedKeyOnDoor in which case it needs to go in those brackets.


For future trouble shooting (x,y) when the game gives you that error those number mean the following


x = which line it is on
y = how many character to the right the problem is occurring at.


if you take a look at the error code (15/1) it is pointing directly at the brackets. specifically the end bracket.
It's not working anyway.
new code? (x,y)
Expected identifier
what are the numbers???

it might be talking about this line


PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);



asSoundName - internal name
asSoundFile - the sound to use + extension .snt
asEntity - the entity to create the sound at, can be “Player”
afFadeTime- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f
abSaveSound - if true, a looping sound will “remember” its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If true, the sound is never attached to the entity! Note that saving should only be used on looping sounds!



this PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
should turn into this
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0f, false);
Sory, its still unexpected token '{'. I putted in brackets under void OnStart as you said. But im getting the same error. And the numbers are 19,1.
I have no problems about door. Door and sound are working perfect. Now my script is

void OnStart()
{
AddEntityCollideCallback("Player", "Ahmet_Quest_Area", "GetAhmetQuest", true, 1);
AddEntityCollideCallback("Player", "Ahmet_Complete_Area", "FinishAhmetQuest", true, 1);
}

void GetTheQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("ahmetquest", "AhmetQuest");
}

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("ahmetquest", "AhmetQuest");
}



{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("TheKey_1");
}


I have a mistake, but i dont know what.

i found a random name on internet. It's ahmet. really i like it Big Grin
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
Read this please.

Okay
Spoiler below!

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("ahmetquest", "AhmetQuest");
}



{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}


the problem with this right here is that everytime you put void EVERYTHING you want to happen in it goes into ONE set of brackets
so
Spoiler below!

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
EVERYTHING YOU WANT TO HAPPEN HERE HAS TO GO HERE INBETWEEN THESE BRACKETS.
}

Here's a rudimentary explanation
whats inside of the brackets define effect. the cause is written in above it. EX.
Spoiler below!

THE CAUSE
void OnStart()

THE EFFECT
{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}

You have some brackets just sitting there in your script randomly. (an effect without a cause) let me show you where exactly
Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "Ahmet_Quest_Area", "GetAhmetQuest", true, 1);
AddEntityCollideCallback("Player", "Ahmet_Complete_Area", "FinishAhmetQuest", true, 1);
}

void GetTheQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("ahmetquest", "AhmetQuest");
}

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("ahmetquest", "AhmetQuest");
}



{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("TheKey_1");
}


THAT is why it is saying that "the { is unexpected because it has no cause so why is there an effect?"
I tried that a hour ago. When u said that I tried your settings as same as mine. But i am getting the same error. Really i read the scripting basics for many times.
(06-15-2013, 09:27 PM)SystemFail Wrote: [ -> ]I tried that a hour ago. When u said that I tried your settings as same as mine. But i am getting the same error. Really i read the scripting basics for many times.

Did you seriously read and understand everything i just wrote that fast?

take a look at your script again and make sure that EVERY effect has a cause. (of which yours doesnt)

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "Ahmet_Quest_Area", "GetAhmetQuest", true, 1);
AddEntityCollideCallback("Player", "Ahmet_Complete_Area", "FinishAhmetQuest", true, 1);
}

void GetTheQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("ahmetquest", "AhmetQuest");
}

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("ahmetquest", "AhmetQuest");
}

// Move this up and get rid of the brackets to void on start because its just using the key on the door. This is a CAUSE. the effect is in red in the next spoiler. \\

{
AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("TheKey_1");
}


Spoiler below!

void OnStart()
{
// this paticular peice here has no effect. its a cause without effect. your effect that this point to would be "void GetAhmetQuest" of which you have non. \\

AddEntityCollideCallback("Player", "Ahmet_Quest_Area", "GetAhmetQuest", true, 1);

// here it happens again. i assume you mean the one in this the code that doesnt have "Ah" in it but programs cant assume \\
AddEntityCollideCallback("Player", "Ahmet_Complete_Area", "FinishAhmetQuest", true, 1);


AddUseItemCallback("", "TheKey_1", "door_1", "UsedKeyOnDoor", true);

}

void GetTheQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("ahmetquest", "AhmetQuest");
}

void FinishTheQuest(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("ahmetquest", "AhmetQuest");
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("TheKey_1");
}

Pages: 1 2