Frictional Games Forum (read-only)
doors problem scirpts - 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: doors problem scirpts (/thread-12080.html)



doors problem scirpts - jessehmusic - 12-25-2011

Hello i got a problem with my key and door script :S
when i have it like this it wont let door be locked
PHP Code:
void OnStart()
{
AddUseItemCallback("""Door key""mansion_1""KeyOnDoor"true); 
AddUseItemCallback("""Old Door key""mansion_5""KeyOnDoor"true); 
}


 
void KeyOnDoor(string &in asItemstring &in asEntity)
 {
     
SetSwingDoorLocked("mansion_1"falsetrue);
     
RemoveItem("Door key");
     
PlaySoundAtEntity("""unlock_door.snt""mansion_1"0.0ftrue);
     
SetSwingDoorLocked("mansion_5"falsetrue);
     
RemoveItem("Old Door key");
     
PlaySoundAtEntity("""unlock_door.snt""mansion_5"0.0ftrue);


If i take that away the doors works to be locked what should i do....

NVM fixed


RE: doors problem scirpts - palistov - 12-26-2011

Your script currently makes both doors unlocked when only one of the keys is used. A simple way you can avoid this is to use an if statement or two to check which door is being unlocked or which key is being used, then run the appropriate lines.

If statements look like this:

PHP Code:
if(Condition)
{
//--- do stuff ---//


So check which key/door is being used by doing if(asItem == "Door key") { //etc etc} or if(asEntity == "mansion_1") { // blah blah }