Jump to content

Recommended Posts

Posted (edited)

In the render window, right click on the second activator, click on edit, go to the scripts tab, right click on the script and click on edit properties, there you need to mark the checkbox for InsideActivator.

 

Also a couple of improvements to show up a different message depending on where from you locked/unlocked the door, and removed the timerId variable.

Scriptname DCF_ManuallyUnlockDoor extends ObjectReference

Bool Property InsideActivator Auto ;'Enable property only for the activator inside the facility.'
ObjectReference xDoor01 ;'This variable is empty until the script is initialized the fist time, so you need a saved game where you never loaded this mod before'

Event OnInit() ;'this event is triggered the first time this script is loaded, which occurs when the cell that contains the activator is loaded for the first time'
	xDoor01 = GetLinkedRef() ; 'this function stores in to the variable the ObjectReference of the door linked to this activator'
	If(xDoor01) ;'this is checking that the variable contains an actual ObjectReference, if a None value is stored then the "else" statement is executed.'
		xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True)
		xDoor01.Lock(abLock = True, abAsOwner = False)
	Else
		Debug.Trace("ERROR: The activator has no linked door")
	EndIf
EndEvent

Event OnActivate(ObjectReference akAction)
	If(xDoor01);'If theres a linked reference'
		If(xDoor01.IsLocked());'if the reference is locked'
			If(Game.GetPlayer().GetItemCount(xDoor01.GetKey()) >= 1 || InsideActivator) ;'Checks if the player has the key of the linked door in the inventory'
				xDoor01.Unlock(abAsOwner = False);'Unlock the door'
				xDoor01.BlockActivation(abBlocked = False, abHideActivateText = False);'enable activation for the door'
				If(InsideActivator)
					Debug.Notification("Door unlocked from inside.")
				Else
					Debug.Notification("Unlocked with the Factory Secret Room Key")
				EndIf
			Else
				Debug.Notification("You need the Factory Secret Room Key to unlock this door")
			EndIf
		Else ;'if the reference is unlocked, as oposite to the if statement being true.'
			If(InsideActivator)
				If !(xDoor01.GetOpenState() > 2) ;'If NOT(closed(3) or closing(4))'
					xDoor01.SetOpen(abOpen = False);'Close it'
				EndIf
				xDoor01.Lock(abLock = True, abAsOwner = False);'Lock it'
				xDoor01.BlockActivation(abBlocked = True, abHideActivateText = True);'Avoid activation and hide activation text.'
				Debug.Notification("Door locked from inside")
			Else
				Debug.Notification("Door already unlocked")
			EndIf
		EndIf
	Else
		Debug.Notification("ERROR: The activator has no linked door")
	EndIf
EndEvent

Edit: I also removed a redundant "if" statement that was checking if the door was unlocked.

Edited by DieFeM
Posted (edited)

Yeahhhhhh :dance: finally it is working like how i wanted to be thanks to you.

I really appreciate it the time you spend to help me out, really you'r the best :thumbsup:

Finally i can upload my mod , thanks again have a nice day :smile:

 

  On 1/3/2019 at 11:03 AM, DieFeM said:

.

Edited by H3S
  • Recently Browsing   0 members

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