Hey! I'm trying to create a script that will automatically close and lock a door a few seconds after use. Not a load door, but a regular animated swinging door. (ImpJailDoor02 is the one i started working on)
I have all of that working, but i have run into two problems:
1: The player can close the door while the script is running, tried to prevent this with the "BlockActivation" function, but i either used it incorrectly or it can't do what i want it to do.
2: Nothing prevents the player from following behind a NPC opening the door. Is there possibly a collision plane that will let through NPCs, but not the player that i can activate and deactivate?
Unrelated tips for cleaning up the script if it's needed is also of course welcome.
For some reason the "code" function of the forums would not save the spaces created with tab key presses making the script a bit annoying to read, apologies for that. Script in question:
Scriptname qqqTestScript01 extends ObjectReference Event OnActivate(ObjectReference akActionRef) If !qqqEaEsDoorGlobal.GetValue() ;Run script if global variable is zero qqqEaEsDoorGlobal.SetValue(1.0) ;Lock the script by setting the global value to something else than zeroself.BlockActivation() If akActionRef == PlayerREF ; Run IF statement if the activator is the player ;Debug.MessageBox("Player Detected") ;Detects and reports who activated the door If (self.IsLocked()) qqqEaEsDoorGlobal.SetValue(0) ;Unlock the script Else Utility.Wait(5) ;Waits X secondsself.PlayGamebryoAnimation ("close", abStartOver = true) ;Plays gamebryoanimation X on objectreferenceUtility.Wait(5) ;Waits X secondsself.Lock(255) ;Locks itself with a value of 255 (requires key)qqqEaEsDoorGlobal.SetValue(0) ;Unlock the script EndIf ElseIf akActionRef != PlayerREF ; Run IF statement if the activator is anyone but the player akActionRef.AddKeyIfNeeded(self) ;Adds key to door to activator if needed (like if it was pickpocketed);Debug.MessageBox ("NPC Detected") ;Detects and reports who activated the doorUtility.Wait(5) ;Waits X secondsself.PlayGamebryoAnimation ("close", abStartOver = true) ;Plays gamebryoanimation X on objectreferenceUtility.Wait(5) ;Waits X secondsself.Lock(255) ;Locks itself with a value of 255 (requires key)qqqEaEsDoorGlobal.SetValue(0) ;Unlock the script EndIf EndIf self.BlockActivation(false) EndEvent Actor Property PlayerRef Auto ;The PlayerGlobalVariable Property qqqEaEsDoorGlobal Auto ;Global variable to prevent spamming "open" on the door