Jump to content

Script help request


Rattlerx5150

Recommended Posts

I have a mod with a heavy security door. the door is locked with a key (Requires Key) in the geck

 

I would like a script that , when the door is closed manually, the door will automatically lock

I dont want the script to force the door closed

 

I dont want to have to use a button or switch to lock the door

 

Can this be done?

Link to comment
Share on other sites

 

DoorScript

Event OnActivate(ObjectReference akActionRef)

If akActionRef == Game.GetPlayer()

If Self.IsLocked() == false

Self.SetOpen(false)

Self.Lock()

EndIf

EndIf

EndEvent

Doesnt work, but thank you anyway

Maybe depends on the lock, works with a usual door for me.What exactly is not working?

Link to comment
Share on other sites

Then it might be something with the door settings. I use similar script that locks and unlocks the settlement door but without using any key. It just works only for player.

But unforunatelly it seems there is no option to set your personal lock. It locks doors with generic novice locks and your key most probably would not work with it.

Link to comment
Share on other sites

Try this:

Scriptname DoorClosenLockScript extends ObjectReference Const

    Event OnClose(ObjectReference akActionRef)
        If akActionRef == Game.GetPlayer()
            If Self.IsLocked() == false
               Self.SetOpen(false)
            Self.Lock()
            Self.SetLockLevel(LockLevel)
        EndIf
    EndIf
    EndEvent

Group  DoorPRoperties
Int Property LockLevel Auto Const
{Level of door lock}
EndGroup

attach that script directly to the door, it should lock the door when it is closed, the property on it 'locklevel' is so you can set the lock level of the door, by default it defaults to novice when you relock a door. lock levels are 1-4, 4 being master

 

there is also a script that you can attach to a trigger box already in the game called CloseLockDoorScript you'd add a default empty trigger on either side of the door, and add the script to it, You want to set the property 'CloseDoor' to true, 'LockDoor' to true, and set the 'LockLevel' then link your trigger to the door using linkcustom01 as the keyword.

 

That triggerbox method would cause the door to automatically close and lock behind the player when they enter the trigger box. you'd have to make sure its set far enough infront of the door to keep the door from pushing the player back out when it closes.

 

Either Method should work fine for you.

Link to comment
Share on other sites

I was actually wrong, decided to test it as I was curious why it won`t work for you. My script works for Covenant doors if adding a locklevel of Covenant doors to it which is zero.

Event OnActivate(ObjectReference akActionRef)
    If akActionRef == Game.GetPlayer()
        If Self. IsLocked() == false
            Self.SetOpen(false)
                Self.Lock()
                SetLockLevel(0)
            else
                Self.UnLock()
                Self.SetOpen()
        EndIf
    EndIf
EndEvent
Link to comment
Share on other sites

 

I was actually wrong, decided to test it as I was curious why it won`t work for you. My script works for Covenant doors if adding a locklevel of Covenant doors to it which is zero.

Event OnActivate(ObjectReference akActionRef)
    If akActionRef == Game.GetPlayer()
        If Self. IsLocked() == false
            Self.SetOpen(false)
                Self.Lock()
                SetLockLevel(0)
            else
                Self.UnLock()
                Self.SetOpen()
        EndIf
    EndIf
EndEvent

 

without trying your script, the problem I see with it is when the player opens the door, it will automatically close and lock on them rather then only locking when the door is closed, hense why I used the event 'OnClose' instead of 'OnActivate', that way the door will only lock if its closed, and will remain open until then.

Link to comment
Share on other sites

 

without trying your script, the problem I see with it is when the player opens the door, it will automatically close and lock on them rather then only locking when the door is closed, hense why I used the event 'OnClose' instead of 'OnActivate', that way the door will only lock if its closed, and will remain open until then.

 

No, it does not do this - it`s a toggle.It does something only when player activates it, one action at a time. Either closes and locks or unlocks and opens. Activating = pressing "E" on the door. I tested it in the game as this is a script I`m using for my settlements just without a lock level and key. Without lock level it won`t let to unlock it with some certain key so for using key need to set a lock level.

 

Just a note that for using it without lock level and key in settlements there should be an additional event like this :

Event OnWorkshopObjectPlaced(ObjectReference akReference)
Self.BlockActivation()
EndEvent
Edited by kitcat81
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...