Jump to content

> Need help: I'm stuck with simple script


Recommended Posts

Hi all,

 

i have been trying all day to make this script working as i wanted. I really tried to figure it out by my self

and come far with it only one line has given me such a headache. So i need your help guys.

 

This is what i was planning to do:

 

I have one DOOR and one ACTIVATOR

The DOOR is locked with a key, so as usual if you activate the DOOR it unlocks (if you have the key :wink:)

So far nothing i have to do. (i add a script for auto close though but that is working fine so no worries)

 

Now my part , if you activate the ACTIVATOR while the DOOR is unlocked it locks the DOOR and

if you activate it again while it is locked it shows a notification that it is already locked.

 

Now everything works fine accept the part where the DOOR already is locked message.

It stays in the second phase where it locked the DOOR i think if someone knows a line like this "(Door01.IsLocked())"

but than the opposite of it. i searched for something like "(.IsUnLocked())" but there isn't such a thing .

I find it really strange that there isn't a simple line as that or is there something similar ? :confused:

 

My Script: i know i must replace "(OpenState == 3 || OpenState == 4)" with something like ".IsUnLockt" or ".GetUnLockState"

Scriptname DCF_ManuallyLockUnlockDoor extends ObjectReference

ObjectReference Property Door01 Auto

Event OnActivate(ObjectReference akAction)
	Int OpenState = Door01.GetOpenState()
	If (OpenState == 1 || OpenState == 2)
		Debug.Notification("Locked with the Button")
		Door01.Activate(Game.GetPlayer())
		Utility.Wait(1.0)
		Door01.Lock()
	ElseIf (OpenState == 3 || OpenState == 4)
		Debug.Notification("Locked with the Button")
		Door01.Lock()
	ElseIf (Door01.IsLocked())
		Debug.Notification("Is already Locked")
	EndIf
EndEvent

All help appreciated :thumbsup:

Edited by H3S
Link to comment
Share on other sites

I think, even a locked door is just a closed door and GetOpenState() will never return anything else than 1,2,3 or 4. Hence, the third statement ( ElseIf (Door01.IsLocked()) ) will never be called.

 

Maybe this will work, though not tested.

Scriptname DCF_ManuallyLockUnlockDoor extends ObjectReference

ObjectReference Property Door01 Auto

Event OnActivate(ObjectReference akAction)
	Int OpenState = Door01.GetOpenState()

	If (Door01.IsLocked())
		Debug.Notification("Is already Locked")
	ElseIf (OpenState == 1 || OpenState == 2)
		Debug.Notification("Locked with the Button")
		Door01.SetOpen(False)
		Utility.Wait(1.0)
		Door01.Lock()
	ElseIf (OpenState == 3 || OpenState == 4)
		Debug.Notification("Locked with the Button")
		Door01.Lock()
	EndIf
EndEvent
Edited by deadbeeftffn
Link to comment
Share on other sites

  • Recently Browsing   0 members

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