Jump to content

Recommended Posts

Posted

When you are using a real key instead of the misc item, maybe the key is removed before the script starts, resulting in the message being displayed regardless

 

Maybe try

Scriptname FXM:FXMscriptMetroTainDoor02 extends ObjectReference

Key Property TheKey Auto
Message Property NoKeyMsg Auto

Event OnActivate (ObjectReference AkActionRef)
If AkActionRef == Game.Getplayer()
    RegisterForPlayerTeleport() ; Add this line to your script
If self.islocked()
NoKeyMsg.show()
Endif
Endif
EndEvent

Event onPlayerTeleport()
ObjectReference DoorRef = (Self as ObjectReference)
DoorRef.Lock()
    DoorRef.SetLockLevel(254) ; so it will require its Key
UnregisterForPlayerTeleport()
EndEvent

 

Posted (edited)

I hope Zorkaz doesn't mind if I rewrote this script:

Scriptname FXM:FXMscriptMetroTainDoor02 extends ObjectReference Const

Key Property myKey Auto Const

Event OnActivate (ObjectReference akActionRef)
	Actor PlayerRef = Game.GetPlayer()	; for optimization
	If akActionRef == PlayerRef
		Int iKeyCount = PlayerRef.GetItemCount(myKey)
		If iKeyCount == 0
			Debug.Notification("I don't have the key.")	; you don't have to create a Message form for a simple message. Of course you can change the text but the quote marks are necessary.
		ElseIf iKeyCount >= 1
			RegisterForPlayerTeleport()
			PlayerRef.RemoveItem(myKey, iKeyCount, abSilent = True)
		EndIf
	EndIf
EndEvent

Event OnPlayerTeleport()
	ObjectReference DoorRef = (Self as ObjectReference)
	DoorRef.Lock()
	DoorRef.SetLockLevel(254)
	UnregisterForPlayerTeleport()
EndEvent
Edited by LarannKiar
Posted

This script works, but the message still posts (Upper left in hud) when teleporting, and all the keys for that type are removed. I would like only a single key to be removed, as the player an purchase multiple keys ("metro pass"). And while I do appreciate the ease of not having to link the same message for every set up, I do like how default messages post in the enter of the screen as opposed to the upper left. Thank you!

Posted
  On 12/23/2021 at 11:21 AM, se7enraven said:

This script works, but the message still posts (Upper left in hud) when teleporting, and all the keys for that type are removed. I would like only a single key to be removed, as the player an purchase multiple keys ("metro pass"). And while I do appreciate the ease of not having to link the same message for every set up, I do like how default messages post in the enter of the screen as opposed to the upper left. Thank you!

 

 

  Reveal hidden contents

 

Posted

Everything works well except two "keys" are still removed. I'm not sure if it matters, but the other door does not have the script on it and is located outside the playable area of the cell. I really do appreciate the help and your patience. Thank You!

  • Recently Browsing   0 members

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