Frictional Games Forum (read-only)
[SCRIPT] Help with a locked doors! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Help with a locked doors! (/thread-15031.html)

Pages: 1 2


Help with a locked doors! - Viuffuz - 04-23-2012

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")
}



RE: Help with a locked doors! - Datguy5 - 04-23-2012

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")
}


RE: Help with a locked doors! - overscore - 04-23-2012

Giving the keys and doors unique names will help with that problem. As shown above.


RE: Help with a locked doors! - Cranky Old Man - 04-23-2012


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);

}



RE: Help with a locked doors! - Viuffuz - 04-23-2012

Thanks Datguy5! It helped! Big Grin



RE: Help with a locked doors! - Datguy5 - 04-24-2012

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

Np glad that i could help.


RE: Help with a locked doors! - FlawlessHappiness - 04-24-2012

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


RE: Help with a locked doors! - Cranky Old Man - 04-24-2012

(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.





RE: Help with a locked doors! - Datguy5 - 04-24-2012

The problem is already solved.No need to fight about it nuff said.


RE: Help with a locked doors! - Cranky Old Man - 04-24-2012

(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.