Script to lock a door at night

Post » Fri May 13, 2011 2:09 pm

Hey guys, I'm trying to get the door to my shop to lock at night but right now it is just constantly locked. I also want it to stay open if the player is in the shop.

If anyone can tell me where I'm going wrong the help would be appreciated:

Here's the script I have atm: (My door is called "cdColdDeckFrontDoor")

Scriptname cdColdDeckFrontDoorObjectScriptBegin GameMode	If Player.GetInCell cdColdDeckGiftShopInt == 1		cdColdDeckFrontDoor.UnlockendifendBegin GameModeIf GetCurrentTime <= 9.00	If GetCurrentTime >= 20.00		cdColdDeckFrontDoor.Unlock 	endifendifendBegin GameModeIf GetCurrentTime >= 9.00	If GetCurrentTime <= 20.30		If Player.GetInCell cdColdDeckGiftShopInt == 0			cdColdDeckFrontDoor.Lock 100		endif	endifendifendBegin GameMode	If Player.GetInCell cdColdDeckGiftShopInt == 1		cdColdDeckFrontDoor.Unlockendifend


Cheers!
User avatar
jasminε
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Sat May 14, 2011 12:05 am

Sorry if this is obvious, but do you understand about "nested if" statements? Suppose you have one if statement inside another, and then inside that you have some commands. The commands only execute if both the if statements are true. So if you write "if a == 1" immediately followed by "if a == 2" the lines inside that will never execute. So, your second gamemode block which you want to unlock the door, never unlocks it. The time cannot be both less than 9, and greater than 20.
User avatar
Dorian Cozens
 
Posts: 3398
Joined: Sat May 26, 2007 9:47 am

Post » Fri May 13, 2011 6:21 pm

Is your shop being run by an npc? If so give him a package that happens while the shop is open, say for example, a standard sandbox package that doesnt allow for a lot of movement that also happens daily, from hours of 10am to 8pm or whatever you want your shop to be open. Then just check the door flags, at package start unlock doors, at package end, lock doors. Can all be done through a single npc package instead of through scripts.

Edit: Unless this is a left over from elder scrolls, though I don't believe it is. Check this page from the old elder scrolls wiki, bottom of the page mentions it. http://cs.elderscrolls.com/constwiki/index.php/Flags_on_Packages
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Fri May 13, 2011 9:26 pm

Thanks for the help guys I'll try these suggestions out =] First time I've scripted owt so you know.. :confused:
User avatar
Batricia Alele
 
Posts: 3360
Joined: Mon Jan 22, 2007 8:12 am

Post » Fri May 13, 2011 4:10 pm

One additional note....as Always Z said, plus you can use the "continue if pc is near" flag to keep the vendor from finishing his locking the doors package until the pc exits the cell.
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm


Return to Fallout: New Vegas