Zorkaz Posted December 22, 2021 Posted December 22, 2021 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 tryScriptname 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
se7enraven Posted December 22, 2021 Author Posted December 22, 2021 Does this version remove the key? I'm not seeing a function (name?) for it?
LarannKiar Posted December 22, 2021 Posted December 22, 2021 (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 December 22, 2021 by LarannKiar
se7enraven Posted December 23, 2021 Author Posted December 23, 2021 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!
LarannKiar Posted December 23, 2021 Posted December 23, 2021 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 Scriptname FXM:FXMscriptMetroTainDoor02 extends ObjectReference Const Key Property myKey Auto Const Message Property myMessage Auto Const Event OnActivate (ObjectReference akActionRef) Actor PlayerRef = Game.GetPlayer() ; for optimization If akActionRef == PlayerRef Int iKeyCount = PlayerRef.GetItemCount(myKey) If iKeyCount == 0 If Self.GetOpenState() == 3 && Self.IsLocked() == 1 myMessage.Show() EndIf ElseIf iKeyCount >= 1 RegisterForPlayerTeleport() PlayerRef.RemoveItem(myKey, 1, abSilent = True) EndIf EndIf EndEvent Event OnPlayerTeleport() ObjectReference DoorRef = (Self as ObjectReference) DoorRef.Lock() DoorRef.SetLockLevel(254) UnregisterForPlayerTeleport() EndEvent
se7enraven Posted December 24, 2021 Author Posted December 24, 2021 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!
Recommended Posts