Jump to content

Unlock and Lock door depending on time


eleglas

Recommended Posts

I'm trying to write a script that will cause a door to close and lock if it is over 8PM and unlock if its over 8AM, but evey attempt to get it working fails, does anyone have an idea how to fix it?

 

My current script is this:

 

scn InfirmarDoorTime

 

Begin OnLoad

 

If GetCurrentTime >= 10

 

InfirmaryDoor.Unlock 1

 

InfirmaryDoor.setOpenState 1

 

EndIf

If GetCurrentTime >= 20

 

InfirmaryDoor.setOpenState 0

 

InfirmaryDoor.lock 1

EndIf

 

If GetCurrentTime << 8

 

InfirmaryDoor.setOpenState 0

 

InfirmaryDoor.lock 1

EndIf

 

END

 

I think there may be something wrong with the Begin statement, but I don't know what else to change it to, any ideas?

Link to comment
Share on other sites

I just threw this together quickly to help you out, it's tested and works. First create a new door object (use another one as a base or whatever), then place it wherever you want it in your cell. Open the properties and give it a new Reference Editor ID (I used TimedDoorREF as you can see in the script), then tick Persistant Reference and close the properties again. Now you've got your reference, you can copy and paste the below script into the GECK and save it (you'll get an error if you try and save the script before you've placed the door reference in a cell). Then open up your custom door again (the original form, not the placed door) and specify the script in the dropdown box next to Script. Save and head in-game to test it, it should work if you've done it right.

A more experienced coder might be able to tidy it up a bit and add some more useful stuff, but this will at least get you started :)

 

scn TimedDoorScript

BEGIN GameMode
if GetCurrentTime >= 8
	TimedDoorREF.Unlock 1
	TimedDoorREF.setOpenState 1
endif

if GetCurrentTime >= 20
	TimedDoorREF.setOpenState 0
	TimedDoorREF.Lock 255	;setting this to 255 = Requires Key.
				;If you want it pickable, 100 = Very Hard, 75 = Hard, 50 = Average, 25 = Easy, 0 = Very Easy
endif

if GetCurrentTime < 8
	TimedDoorREF.setOpenState 0
	TimedDoorREF.Lock 255
endif
END

 

quick edit: one note I forgot to mention, you'll probably notice I switched the order around for setOpenState and Lock, this is because setting the door to lock before setting it to close basically makes the door magically close with no animation when it hits 8pm, you need to close the door first, then lock it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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