FirstVaultDweller Posted January 1, 2019 Share Posted January 1, 2019 Hi all, Does someone know how you can unlock a door only with a activator ?but you must still be able to open the door when you activate it after you unlock it with the activator.(so basically you can only interact with the door if it is in unlocked state) I can't figure it out. I tried "OnLockStateChanged()" ".BlockActivation()" and couple more but it does nothing what did i wrong ? What event or statement i have to put in my script and should i attach it to the door or activator ? :confused:I would appreciate it if someone can help me out :smile: Script that is attached to the Activator: Scriptname DCF_ManuallyUnlockDoor extends ObjectReference ObjectReference Property xDoor01 Auto Event OnActivate(ObjectReference akAction) If (xDoor01.IsLocked()) Debug.Notification("Unlocked with the Factory Secret Room Key") xDoor01.Unlock() EndIf EndEvent Script that is attached to the Door: Scriptname DCF_AutoCloseDoorScript extends ObjectReference Event OnOpen(ObjectReference akActionRef) StartTimer(5.0) EndEvent Event OnTimer(int timerID) if timerID == 0 SetOpen(False) endif EndEvent I used this event with the door but does nothing : Event OnInit() If (IsLocked()) BlockActivation(True) Else BlockActivation(False) EndIf EndEvent Link to comment Share on other sites More sharing options...
FirstVaultDweller Posted January 1, 2019 Author Share Posted January 1, 2019 (edited) Finally :smile: after long time searching i find a solution . I used the lock type of the door as Inaccessible instead of a key sois working now and used this " xDoor01.SetLockLevel(254) " in the lock script to be Inaccessible again if it's locked.Only the player says things like "Broken,cant pick this" but not a big deal this is the closes what i found. And only one thing left and that is to use the key that was meant for the door with the activator(so without key can't use it).Ill try to find a solution for that also. In the meantime help and suggestions are always welcome :thumbsup: Edited January 1, 2019 by H3S Link to comment Share on other sites More sharing options...
DieFeM Posted January 1, 2019 Share Posted January 1, 2019 (edited) I was bored... so I've done this script, it only needs this script to be attached on the activator: Scriptname DCF_ManuallyUnlockDoor extends ObjectReference ObjectReference xDoor01 Int OpenDoorTimer = 111 Event OnInit() xDoor01 = GetLinkedRef() If(xDoor01) xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True) xDoor01.Lock(abLock = True, abAsOwner = False) RegisterForRemoteEvent(xDoor01, "OnOpen") Else Debug.Trace("ERROR: The activator has no linked door") EndIf EndEvent ;; events for the door Event ObjectReference.OnOpen(ObjectReference doorRef, ObjectReference akActionRef) If(doorRef == xDoor01 && akActionRef == Game.GetPlayer()) StartTimer(afInterval = 5.0, aiTimerID = OpenDoorTimer) EndIf EndEvent Event OnTimer(int aiTimerID) If(aiTimerID == OpenDoorTimer) If !(xDoor01.GetOpenState() > 2) ;If NOT(closed(3) or closing(4)) xDoor01.SetOpen(abOpen = False); Close it EndIf If(!xDoor01.IsLocked());If NOT locked xDoor01.Lock(abLock = True, abAsOwner = False); Lock it EndIf xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True);Avoid activation and hide activation text. EndIf EndEvent ; events for the activator Event OnActivate(ObjectReference akAction) If(xDoor01);If theres a linked reference If(xDoor01.IsLocked());if the reference is locked xDoor01.Unlock(abAsOwner = False); Unlock the door xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False); enable activation for the door Debug.Notification("Unlocked with the Factory Secret Room Key") Else Debug.Notification("Door already unlocked") EndIf Else Debug.Notification("ERROR: The activator has no linked door") EndIf EndEvent You need to link the activator to the door instead of entering the door reference as property, to do so click on the activator, then pres ctrl+space (a crosshair pointer will appear), click on the door and (if the objects in the dialog box are the correct ones and "set linked ref" is selected) click ok. Or you can also link the door to the activator from the activator properties (right click->edit) by setting the door as linked reference in the "linked ref" tab. Edited January 1, 2019 by DieFeM Link to comment Share on other sites More sharing options...
DieFeM Posted January 1, 2019 Share Posted January 1, 2019 (edited) Finally :smile: after long time searching i find a solution . I used the lock type of the door as Inaccessible instead of a key sois working now and used this " xDoor01.SetLockLevel(254) " in the lock script to be Inaccessible again if it's locked.Only the player says things like "Broken,cant pick this" but not a big deal this is the closes what i found. And only one thing left and that is to use the key that was meant for the door with the activator(so without key can't use it).Ill try to find a solution for that also. In the meantime help and suggestions are always welcome :thumbsup: You can use this: If(Game.GetPlayer().GetItemCount(xDoor01.GetKey()) >= 1) xDoor01.Unlock(abAsOwner = False); Unlock the door xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False); enable activation for the door Debug.Notification("Unlocked with the Factory Secret Room Key") EndIf Edited January 1, 2019 by DieFeM Link to comment Share on other sites More sharing options...
FirstVaultDweller Posted January 1, 2019 Author Share Posted January 1, 2019 (edited) Thanks i don't know where to put the statement for the key cuz it getting to much for me now :confused: sorry not so much experience with scripting? and BTW sorry i didn't mention it before i thought it is gonna be a easy one line script that i can copyand use it to the second activator so have total of two activators .To lock/unlock with the activators you need the key of that door. If the door is unlocked you need to be able to open it with the door only. Sorry English is not my first language, i hope i explained it better now and is clear what i wanna to achieve.One Locks the door and one Unlocks the door should i use exact the same script to that ? If you pleas can tel me what script i should have for both activators (Lock&Unlock) i really would appreciated :smile: Script to attach Activator 1(Unlock door): Post#3 Script i have for Activator 2 (Lock door) Scriptname DCF_ManuallyLockDoor extends ObjectReference ObjectReference Property xDoor01 Auto ObjectReference Property xKeyLock01 Auto Event OnActivate(ObjectReference akAction) Int OpenState = xDoor01.GetOpenState() If (OpenState == 1 || OpenState == 2) Debug.Notification("Can't lock it now") ElseIf (OpenState == 3 || OpenState == 4) Debug.Notification("Door Is Locked Now") xDoor01.Lock() xKeyLock01.Enable() Disable() EndIf EndEvent Edited January 1, 2019 by H3S Link to comment Share on other sites More sharing options...
FirstVaultDweller Posted January 1, 2019 Author Share Posted January 1, 2019 I linked to activator to the door but i still get the message "ERROR: The activator has no linked door" :confused: Link to comment Share on other sites More sharing options...
DieFeM Posted January 2, 2019 Share Posted January 2, 2019 (edited) Thanks i don't know where to put the statement for the key cuz it getting to much for me now :confused: sorry not so much experience with scripting Scriptname DCF_ManuallyUnlockDoor extends ObjectReference ObjectReference xDoor01 ;'This variable is empty until the script is initialized the fist time, so you need a saved game where you never loaded this mod before' Int OpenDoorTimer = 111 ;'This variable stores a random number to identify the timer I used to automatically close and lock the door after 5 seconds of being open by the player' Event OnInit() ;'this event is triggered the first time this script is loaded, which occurs when the cell that contains the activator is loaded for the first time' xDoor01 = GetLinkedRef() ; 'this function stores in to the variable the ObjectReference of the door linked to this activator' If(xDoor01) ;'this is checking that the variable contains an actual ObjectReference, if a None value is stored then the "else" statement is executed.' xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True) xDoor01.Lock(abLock = True, abAsOwner = False) RegisterForRemoteEvent(xDoor01, "OnOpen") ;'Registers for the OnOpen event on the ObjectReference of the linked door which is defined bellow this event.' Else Debug.Trace("ERROR: The activator has no linked door") EndIf EndEvent ;;'events for the door' Event ObjectReference.OnOpen(ObjectReference doorRef, ObjectReference akActionRef) If(doorRef == xDoor01 && akActionRef == Game.GetPlayer()) StartTimer(afInterval = 5.0, aiTimerID = OpenDoorTimer);'this function starts a 5 seconds timer, what will happen after 5 seconds is described in the OnTimer event bellow this one' EndIf EndEvent Event OnTimer(int aiTimerID) If(aiTimerID == OpenDoorTimer) If !(xDoor01.GetOpenState() > 2) ;'If NOT(closed(3) or closing(4))' xDoor01.SetOpen(abOpen = False);'Close it' EndIf If(!xDoor01.IsLocked());'If NOT locked' xDoor01.Lock(abLock = True, abAsOwner = False);'Lock it' EndIf xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True);'Avoid activation and hide activation text.' EndIf EndEvent ;'events for the activator' Event OnActivate(ObjectReference akAction) If(xDoor01);'If theres a linked reference' If(xDoor01.IsLocked());'if the reference is locked' If(Game.GetPlayer().GetItemCount(xDoor01.GetKey()) >= 1) ;'Checks if the player has the key of the linked door in the inventory' xDoor01.Unlock(abAsOwner = False);'Unlock the door' xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False);'enable activation for the door' Debug.Notification("Unlocked with the Factory Secret Room Key") Else Debug.Notification("You need the Factory Secret Room Key to unlock this door") EndIf Else Debug.Notification("Door already unlocked") EndIf Else Debug.Notification("ERROR: The activator has no linked door") EndIf EndEvent I've added some comments to the script that might be of help understanding the script. If you have doubts on what something does don't be afraid of asking.And make sure to load a saved game where you didn't loaded this mod before in order to test it properly. EDIT: I've quoted the comments with single quotes(') so the highlighting of this site shows the comments as strings, so they are easier to read. Edited January 2, 2019 by DieFeM Link to comment Share on other sites More sharing options...
FirstVaultDweller Posted January 2, 2019 Author Share Posted January 2, 2019 (edited) WoW :ohmy: thanks man really appreciate it, it works but when the timer was on 0 it locked the door it should be stay in unlocked state till i locked it my self again so i tweaked this 2 statements : If(!xDoor01.IsLocked());'If NOT locked' xDoor01.Lock(abLock = True, abAsOwner = False);'Lock it' EndIf xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True);'Avoid activation and hide activation text.' in to this: If(!xDoor01.IsLocked());'If NOT locked' xDoor01.Lock(abLock =False, abAsOwner = True);'Lock it' EndIf xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False);'Avoid activation and hide activation text.' i don't now if this is the correct way to do it but it works now and i wanted to apply this to my other activator to lock the door back again but can't cuz there isn't a opposite of IsLocked() something like IsUnlocked() i can't figure it out :confused:do i need a hole new script for that or can that be done in the same script and if it's to complicated ill stick on one activator i am already happy that i have something that unlocks.? :smile: Edited January 2, 2019 by H3S Link to comment Share on other sites More sharing options...
DieFeM Posted January 3, 2019 Share Posted January 3, 2019 (edited) There's another version which don't close the door automatically, but you can use it for the inside activator as well (you can use it in both activators). There is a property that you must mark the checkbox for the second activator (change the property of the script in the reference, not in the base object): Scriptname DCF_ManuallyUnlockDoor extends ObjectReference Bool Property InsideActivator Auto ;'Enable property only for the activator inside of the facility.' ObjectReference xDoor01 ;'This variable is empty until the script is initialized the fist time, so you need a saved game where you never loaded this mod before' Int OpenDoorTimer = 111 ;'This variable stores a random number to identify the timer I used to automatically close and lock the door after 5 seconds of being open by the player' Event OnInit() ;'this event is triggered the first time this script is loaded, which occurs when the cell that contains the activator is loaded for the first time' xDoor01 = GetLinkedRef() ; 'this function stores in to the variable the ObjectReference of the door linked to this activator' If(xDoor01) ;'this is checking that the variable contains an actual ObjectReference, if a None value is stored then the "else" statement is executed.' xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True) xDoor01.Lock(abLock = True, abAsOwner = False) Else Debug.Trace("ERROR: The activator has no linked door") EndIf EndEvent Event OnActivate(ObjectReference akAction) If(xDoor01);'If theres a linked reference' If(xDoor01.IsLocked());'if the reference is locked' If(Game.GetPlayer().GetItemCount(xDoor01.GetKey()) >= 1 || InsideActivator) ;'Checks if the player has the key of the linked door in the inventory OR is already inside of the facility' xDoor01.Unlock(abAsOwner = False);'Unlock the door' xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False);'enable activation for the door' Debug.Notification("Unlocked with the Factory Secret Room Key") Else Debug.Notification("You need the Factory Secret Room Key to unlock this door") EndIf Else ;'if the reference is unlocked, as oposite to the if statement being true.' If(InsideActivator) If !(xDoor01.GetOpenState() > 2) ;'If NOT(closed(3) or closing(4))' xDoor01.SetOpen(abOpen = False);'Close it' EndIf If(!xDoor01.IsLocked());'If NOT locked' xDoor01.Lock(abLock = True, abAsOwner = False);'Lock it' EndIf xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True);'Avoid activation and hide activation text.' Else Debug.Notification("Door already unlocked") EndIf EndIf Else Debug.Notification("ERROR: The activator has no linked door") EndIf EndEvent Edited January 3, 2019 by DieFeM Link to comment Share on other sites More sharing options...
FirstVaultDweller Posted January 3, 2019 Author Share Posted January 3, 2019 (edited) So i can use this script allso the the other activator to lock the door but which property or what makes it that it locks the door? I didn't understand exactly how or where i can find that checkbox?In the meantime ill try to find such a checkbox. Edited January 3, 2019 by H3S Link to comment Share on other sites More sharing options...
Recommended Posts