Coinkidoink Posted May 22, 2014 Share Posted May 22, 2014 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: Reveal hidden contents 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 zero self.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 seconds self.PlayGamebryoAnimation ("close", abStartOver = true) ;Plays gamebryoanimation X on objectreference Utility.Wait(5) ;Waits X seconds self.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 door Utility.Wait(5) ;Waits X seconds self.PlayGamebryoAnimation ("close", abStartOver = true) ;Plays gamebryoanimation X on objectreference Utility.Wait(5) ;Waits X seconds self.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 Player GlobalVariable Property qqqEaEsDoorGlobal Auto ;Global variable to prevent spamming "open" on the door Link to comment Share on other sites More sharing options...
Recommended Posts