Frictional Games Forum (read-only)

Full Version: Help with a locked doors!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have two locked doors in the same level and when I open the first door with a key, it opens the other door at the same time. Why does this happen?

Here's the script!

void OnStart ()
{
AddUseItemCallback("", "Avain", "mansion_3", "UsedKeyOnDoor", true);
AddUseItemCallback("", "pihan_avain", "mansion_11", "UsedKeyOnDoor", true);
}

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

SetSwingDoorLocked("mansion_11", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_11", 0, false);
RemoveItem("pihan_avain")
}
You should put bracket between the removeitem and setswingdoor locked
because if they are in the same they will both open.Try this:

void OnStart ()
{
AddUseItemCallback("", "Avain", "mansion_3", "UsedKeyOnDoor", true);
AddUseItemCallback("", "pihan_avain", "mansion_11", "UsedKeyOnDoor2", true);
}

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

SetSwingDoorLocked("mansion_11", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_11", 0, false);
RemoveItem("pihan_avain")
}
Giving the keys and doors unique names will help with that problem. As shown above.

If YourComputer was here, he would frown.

Just do this:

Code:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{

SetSwingDoorLocked(asEntity, false, true);

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

RemoveItem(asItem);

}
Thanks Datguy5! It helped! Big Grin
(04-23-2012, 08:15 PM)Viuffuz Wrote: [ -> ]Thanks Datguy5! It helped! Big Grin

Np glad that i could help.
The problem was that both of your scripts were called void UsedKeyOnDoor
Datguy5 called one of them UsedKeyOnDoor2. And also edited in the
void OnStart script Wink

Just so it won't happen again
(04-24-2012, 07:07 PM)beecake Wrote: [ -> ]The problem was that both of your scripts were called void UsedKeyOnDoor
Datguy5 called one of them UsedKeyOnDoor2. And also edited in the
void OnStart script Wink

Just so it won't happen again
Dude, just use my script. It's half the size, and you can use it for 50 doors if you want.


The problem is already solved.No need to fight about it nuff said.
(04-24-2012, 07:37 PM)Datguy5 Wrote: [ -> ]The problem is already solved.No need to fight about it nuff said.
I'm not "fighting you". I'm talking about using efficient code. Would there be a woman involved somewhere, then I could possibly fight you, but there's no point in "fighting" on these forums.
Pages: 1 2