Frictional Games Forum (read-only)

Full Version: Error at unlocking door with an item
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It says:

"FATAL ERROR: main (21,23) : ERR : Expected identifier"

This is a copy of the .hps file:


Quote:////////////////////////////
// Run when the map starts
void OnStart()
{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

AddUseItemCallback("", "secret1", "lckd", "unlock", true);

void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(lckd, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem(secret1);
}

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

}

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

}
secret1 = Key name
lckd = Locked door name

PS: I don't know if it might have something to do with the error. But the key you must use, you get it on the level before this one.
AddUseItemCallback("", "secret1", "lckd", "unlock", true);
It's in no function. It will never be called(that's why that error is there).
(07-07-2012, 10:40 PM)FastHunteR Wrote: [ -> ]AddUseItemCallback("", "secret1", "lckd", "unlock", true);
It's in no function. It will never be called(that's why that error is there).
I don't understand. I've already been nearly thirty minutes trying to fix this script and i think i'll get mad. Would you please correct my script and paste it in a reply?

Thanks in advance
I have no idea when you plan to add that callback, since I can't read your mind. Cut that line of it out and paste it, I assume under OnStart().
I finally could make it work. Thanks, what you said was right, but i didn't understand it well. So the problem's solved. Thanks again for the help
also
RemoveItem(secret1); should be
RemoveItem("secret1"); shouldn't it?
(07-08-2012, 12:11 AM)beecake Wrote: [ -> ]also
RemoveItem(secret1); should be
RemoveItem("secret1"); shouldn't it?
I've actually left it as
Quote: RemoveItem(asItem);
and it's working perfectly