Jump to content

Scripting Help


ben446

Recommended Posts

Ok some im using a script that is a modders resource. Its a script that will make a key also lock a door. I did manage to adjust it before for what I wanted. Basically I wanted it so one key would open and lock a lot of doors. But since then I had to reinstall my whole laptop and cannot remember how I adjusted it before.

 

ObjectReference Property Door01 auto

ObjectReference Property Door02 auto

 

String Property LOCKMESSAGE auto

 

Event OnEquipped (Actor akActor)

 

Int OpenState = Door01.GetOpenState()

 

If (OpenState == 1 || OpenState ==2)

 

 

debug.notification (LOCKMESSAGE)

Door01.Activate(Game.GetPlayer))

Utility.Wait(1.5)

Door01.Lock()

 

Else

 

Debug.notification(LOCKMESSAGE)

Door01.Lock()

 

Else

 

debug.notification(LOCKMESSAGE)

Door02.Activate(Game.GetPLayer))

Utility.Wait(1.5)

DOor02.Lock()

 

Else

 

Debug.notification(LOCKMESSAGE)

Door02.Lock()

 

EndIf

EndEvent

 

 

If someone could help me correct my mistake and show me how to add more doors itd be greatly appreciated. Im currently working on a large home/CHeat/Adventure Mod. Id like to make it so the home section of the mod will have a master key that will open the main house the armoury and some other areas. As I say I did manage to sort this before but had to reinstall my laptop. Last time I worked on this mod I believe it was about 19 doors that was all linked to the one key

 

Thank you very much for all your help in advance

Edited by ben446
Link to comment
Share on other sites

  • 2 weeks later...

This is still a subject I really need help with. if I have to do it so one key locks one door and one door only im gonna have to have about 30 keys for the whole mod. so having help to adapt this script will make things so much easier and will cut down on the amount of keys needed.

 

Thanks for all your help

Link to comment
Share on other sites

I think maybe the script could be like this:

 

Scriptname MyDoorNLockScript Extends ObjectReference
{insertcommentshere}

Formlist Property DoorsInHouse Auto
;fill this formlist with those doors. Remember that door ID must match with the key ID or it will not work (I.E. door 0 for key 0)

Formlist Property KeyForZeDoor Auto
;fill this formlist with those keys. Remember that key ID must match with the door ID or it will not work (I.E. key 0 for door 0)

ObjectReference Property MyMasterKey Auto
Actor Property PlayerRef Auto

Message Property UnlockMessage Auto
Message Property LockMessage Auto
;You may set these message properties into an array, if you fancy naming those doors. You also need to determine which message is used when the master key unlocks a certain named door.

Event OnActivate(ObjectReference akActionRef)
    if PlayerRef.GetItemCount(MyMasterKey) == 0
        int i = 0
        int imax = DoorsInHouse.GetSize()
        while i < imax
            if PlayerRef.GetItemCount(KeyForZeDoor.GetAt(i) as ObjectReference) > 0 && Self as Form == DoorsInhouse.GetAt(i)
                if Self.IsLocked()
                    UnlockMessage.Show()
                    Self.Lock(false)
                    Self.Activate(PlayerRef)
                else
                    LockMessage.Show()
                    Utility.Wait(1.5)
                    Self.Lock()
                endif
            endif
            i += 1
        endwhile
    else
        if Self.IsLocked()
            UnlockMessage.Show()
            Self.Lock(false)
            Self.Activate(PlayerRef)
        else
           LockMessage.Show()
           Utility.Wait(1.5)
           Self.Lock()
        endif
    endif
EndEvent

 

 

 

But you must attach this script to each door, after assigning them into the formlist mentioned on the script.

Edited by Flamekun
Link to comment
Share on other sites

thank you so much for your help the script I was using was assigned to the key. as I said I did manage to adapt it before but when I had issues with my laptop I lost the adapted script. but having it so I can lock and unlock about 30ish doors with on key makes things so much easier .

 

Thank you so much for all your help

Link to comment
Share on other sites

  • Recently Browsing   0 members

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