Frictional Games Forum (read-only)

Full Version: HELP!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am making a new custom story and i am naming it "Forever" i am having troubles with scripting, though,
here is what i have in there,


////////////////////////////
//Run when starting map
void OnStart()

{
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
}


void Explode(string &in asParent, string &in asChild, int alState)

{
SetPropHealth("boom", 0);
}

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

{
AddUseItemCallback("", "key", "Locked Door", "KeyOnDoor", true);
}


{
SetSwingDoorLocked("Locked Door", false, true);
PlaySoundEntity("", "unlock_door", "Locked Door", 0, false);
RemoveItem("key");
}

///////////////////////////////
// Run when entering map
void OnEnter()
{

}

//////////////////////////////
// Run when leaving map
void OnLeave()
{
}

,everytime i go in the game it says "unexpected token "{"
any revisions would be greatly appreciated, and hopefully i will figure everything out from there.
thanks, bye.
2 main issues:

Lock Door isn't a valid string; you should never use spaces in the middle of a string name, just use underscores "_". I changed it to locked_door in the hps file; you should use that name in the level editor.

All callbacks (AddUseItemCallback, EntityCollideCallback, etc) go under void OnStart().


Here's a revision:


void OnStart()
{
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
AddUseItemCallback("", "key", "locked_door", "KeyOnDoor", true); ///not Lock Door
}


void Explode(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("boom", 0);
}


void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door", false, true);
PlaySoundEntity("", "unlock_door", "locked_door", 0, false);
RemoveItem("key");
}


void OnEnter()
{


}


void OnLeave()
{


}


Hope that helped!
now it's having problems with the sound...i'll just remove it and see what happens

thank you though, i felt kind of hopeless when i couldnt figure out how to get a door to unlock XD
The sound problem was that you wrote: PlaySoundEntity.
It's: PlaySoundAtEntity