Trouble with a door locking script

Post » Tue Sep 02, 2014 5:32 am

Okay, well I'm trying to make a script to put on a door that will lock it automatically when you shut it. But it's not working :( I keep getting the error 'missing EOF at 'if'' :/ If anyone could help me with this I'd be very grateful, thank you.

Here's the script I've tried:

scriptname VaultDoorScriptfloat timershort doWhatBegin GameMode    if ( getlocked )    else        if timer > 0            set timer to timer - getsecondspassed        else            if doWhat == 0                set timer to timer + 1                set doWhat to 1                return            elseif doWhat == 1                lock 100                set doWhat to 0                return            endif        endif    endifEnd
User avatar
Rob Davidson
 
Posts: 3422
Joined: Thu Aug 02, 2007 2:52 am

Post » Mon Sep 01, 2014 5:30 pm

This is not a Papyrus Script. It's a Oblivion (Construction Set) script.

Take a look at the http://www.creationkit.com/OnClose_-_ObjectReference event.

User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am

Post » Tue Sep 02, 2014 9:20 am

Oh god oops, my bad >.< Okay, well there is another script I have tried that also didn't work and gave me the same error:

Scriptname VaultDoorScript3    Short Open Begin OnActivate   If open != 1    DoorRef.Unlock    DoorRef.Activate    Set Open to 1  Elseif Open == 1    DooRef.Activate    DoorRef.Lock LockLevel    set open to 0  Endif End
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Mon Sep 01, 2014 6:37 pm

Okay I'm looking at the OnClose() event now and I'm gonna right a new script from scratch and see if it works

User avatar
Samantha Mitchell
 
Posts: 3459
Joined: Mon Nov 13, 2006 8:33 pm

Post » Tue Sep 02, 2014 7:18 am

Damn it just realised that's an oblivion script too, sorry!!

User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Mon Sep 01, 2014 6:09 pm

Use this script as a base for your work. Put it on your door.

ScriptName myLockDoorScript extends ObjectReferenceEvent OnClose(ObjectReference akActionRef)	if (akActionRef == Game.GetPlayer())		Debug.Trace("We were closed by the player")		Self.SetLockLevel(25) ;locklevel Apprentice (25)		Self.Lock()	else		Debug.Trace("Someone (or something) else closed us")	endifEndEvent
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Mon Sep 01, 2014 5:56 pm

Thanks! :)

User avatar
Lil Miss
 
Posts: 3373
Joined: Thu Nov 23, 2006 12:57 pm

Post » Mon Sep 01, 2014 7:09 pm

Okay I tried the script you posted, but set the locklevel to 100 because the door requires a key. But, it didn't work :( So then I tried this. It's probably completely wrong as I'm terrible at scripting, but hopefully you can help me out with it, or tell me to scrap it if it is complete nonsense.

Scriptname EsbernVaultDoorScript4 extends ObjectReference   Event OnClose(ObjectReference akActionRef)if (akActionRef == Game.GetPlayer())Debug.Trace("We were closed by the player")Function Lock(bool abLock = true, bool abAsOwner = false) nativeMQ202EsbernsDoorREF.SetLockLevel(100) ;locklevel Requires Key (100)MQ202EsbernsDoorREF.Lock()EndifelseDebug.Trace("Someone (or something) else closed us")endifEndEventDoor Property MQ202EsbernsDoorREF  Auto  
User avatar
Dawn Farrell
 
Posts: 3522
Joined: Thu Aug 23, 2007 9:02 am

Post » Mon Sep 01, 2014 11:17 pm

Hi,

the SetLockLevel() and Lock() functions are members of the ObjectReference script, not the Door script.

Put my script on the door reference you want to have to be lock.

Or (and that's even better), create a Quest and make an alias for the door. If you decide for the Quest solution, you have to slightly change the script:

Scriptname myDoorAliasScript extends ReferenceAlias Event OnClose(ObjectReference akActionRef)	if (akActionRef == Game.GetPlayer())		Debug.Trace("We were closed by the player")		GetReference().SetLockLevel(100) ;locklevel Requires Key (100)		GetReference().Lock()	else		Debug.Trace("Someone (or something) else closed us")	endifEndEvent
User avatar
katie TWAVA
 
Posts: 3452
Joined: Tue Jul 04, 2006 3:32 am

Post » Tue Sep 02, 2014 7:33 am

I believe you need lock level 255 to indicate the door requires a key. 100 is just difficult lock level or something like that.

User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm

Post » Tue Sep 02, 2014 3:45 am

Correct! http://www.creationkit.com/SetLockLevel_-_ObjectReference

User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Mon Sep 01, 2014 8:54 pm

One thing more. If you set the lock level to 'requires key', then there must be a key 'assigned' to that door before. Otherwise it's impossible to open that door again. I'm not aware of any function to 'assign' a key to a door via script.

User avatar
Unstoppable Judge
 
Posts: 3337
Joined: Sat Jul 29, 2006 11:22 pm


Return to V - Skyrim