Frictional Games Forum (read-only)

Full Version: Doors unlocked after picking up the key?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My doors were working just fine this morning but after adding some scripting now my doors unlock as soon as I pick up there respective keys rather than waiting till I use them. I check the scripting and nothing has changed. Thats the script, what is wrong?

void OnStart()
{
}

void OnEnter()
{
AddUseItemCallback("", "Study_Closet_Key", "Study_Closet", "KeyOnDoor", true);
AddUseItemCallback("", "hallway_key_1", "hallway_door_1", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "hallway_door_slam_1", "func_slam", true, 1);
SetEntityPlayerInteractCallback("mansion_4", "func_slam", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Study_Closet", false, true);
PlaySoundAtEntity("", "unlock_door", "Study_Closet", 0, false);
RemoveItem("Study_Closet_Key");
SetSwingDoorLocked("hallway_door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "hallway_door_1", 0, false);
RemoveItem("hallway_key_1");
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("hallway_door_2", 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);
}

void func_slam(string &in asEntity)
{
SetPropHealth("mansion_4", 0.0f);


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


void OnLeave()
{
}
Your script shows that unlocking one door unlocks both doors, but it doesn't show that they unlock when picking up a key.
(10-17-2011, 05:31 AM)Your Computer Wrote: [ -> ]Your script shows that unlocking one door unlocks both doors, but it doesn't show that they unlock when picking up a key.
Where are you seeing that at and what alterations should I make to fix it?
(10-17-2011, 05:33 AM)Darkdevil725 Wrote: [ -> ]Where are you seeing that at and what alterations should I make to fix it?

Replace this:
Code:
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Study_Closet", false, true);
PlaySoundAtEntity("", "unlock_door", "Study_Closet", 0, false);
RemoveItem("Study_Closet_Key");
SetSwingDoorLocked("hallway_door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "hallway_door_1", 0, false);
RemoveItem("hallway_key_1");
}

With:
Code:
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
THANKS!