ryan223456
Junior Member
Posts: 2
Threads: 1
Joined: Aug 2012
Reputation:
0
|
HELP!
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.
|
|
08-25-2012, 04:45 AM |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
RE: HELP!
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!
I rate it 3 memes.
(This post was last modified: 08-25-2012, 04:54 AM by Adny.)
|
|
08-25-2012, 04:53 AM |
|
ryan223456
Junior Member
Posts: 2
Threads: 1
Joined: Aug 2012
Reputation:
0
|
RE: HELP!
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
(This post was last modified: 08-25-2012, 06:09 PM by ryan223456.)
|
|
08-25-2012, 05:50 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: HELP!
The sound problem was that you wrote: PlaySoundEntity.
It's: PlaySoundAtEntity
Trying is the first step to success.
|
|
08-25-2012, 06:26 PM |
|
|