Frictional Games Forum (read-only)

Full Version: doors problem scirpts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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 }