Jump to content

Travel Message Box


Recommended Posts

How would I attach a message to a door? Assuming I need some kind of script that calls up the message box when the player clicks on the door?

 

Already have the message just not sure how to attach it. Want to give the option to the player to stay in the commonwealth or travel to my custom world location.

Link to comment
Share on other sites

One outline approach (of many);

 

Put an invisible activator in front of the door with your door name and activation text.

Make nokeyword LinkedReference from the activator to the door.

Attach script to activator with event OnActivate() that shows the menu messagebox and activates the linkedref door if that menu option is selected.

Link to comment
Share on other sites

If it's not a vanilla door, you can safely attach a script like this to the door.

 

 

Scriptname ShowMessageOnDoorActivate extends ObjectReference Const

Message Property MessageToShow Auto Const


Event OnInit()
	Utility.Wait(0.5)
	BlockDoor(Block = True)
EndEvent

Event OnLoad()
	BlockDoor(Block = True)
EndEvent

Event OnActivate(ObjectReference akActionRef)
	Actor PlayerRef = Game.GetPlayer()
	; if the door got activated by the player
	If akActionRef == PlayerRef
		; if the door can't be activated however
		If Self.IsActivationBlocked() == True
			Int ButtonIndex = MessageToShow.Show()
			; if the menu button at Index 0 says something like 'Yes, I'd like to travel'
			; script activate the door by the player
			If ButtonIndex == 0
				BlockDoor(Block = False)
				Self.Activate(akActivator = PlayerRef)
				Utility.Wait(0.2)
				BlockDoor(Block = True)
			; otherwise, if the menu button at Index 1 says something like 'Let me think it over'
			ElseIf ButtonIndex == 1
				; do nothing
			; otherwise
			Else
				; do nothing
			EndIf
		Else
			; error, activation should be blocked
		EndIf
	EndIf
EndEvent

Function BlockDoor(bool Block = True)
	If Self.IsActivationBlocked() != Block
		Self.BlockActivation(Block)
	EndIf
EndFunction 

 

 

I haven't tested it but it should work..

Edited by LarannKiar
Link to comment
Share on other sites

If it's not a vanilla door, you can safely attach a script like this to the door.

 

 

Scriptname ShowMessageOnDoorActivate extends ObjectReference Const

Message Property MessageToShow Auto Const


Event OnInit()
	Utility.Wait(0.5)
	BlockDoor(Block = True)
EndEvent

Event OnLoad()
	BlockDoor(Block = True)
EndEvent

Event OnActivate(ObjectReference akActionRef)
	Actor PlayerRef = Game.GetPlayer()
	; if the door got activated by the player
	If akActionRef == PlayerRef
		; if the door can't be activated however
		If Self.IsActivationBlocked() == True
			Int ButtonIndex = MessageToShow.Show()
			; if the menu button at Index 0 says something like 'Yes, I'd like to travel'
			; script activate the door by the player
			If ButtonIndex == 0
				BlockDoor(Block = False)
				Self.Activate(akActivator = PlayerRef)
				Utility.Wait(0.2)
				BlockDoor(Block = True)
			; otherwise, if the menu button at Index 1 says something like 'Let me think it over'
			ElseIf ButtonIndex == 1
				; do nothing
			; otherwise
			Else
				; do nothing
			EndIf
		Else
			; error, activation should be blocked
		EndIf
	EndIf
EndEvent

Function BlockDoor(bool Block = True)
	If Self.IsActivationBlocked() != Block
		Self.BlockActivation(Block)
	EndIf
EndFunction 

 

 

I haven't tested it but it should work..

So i got an error message about the last EndIf line "(38,0): missing EndOfFile at 'endif'"

Link to comment
Share on other sites

 

If it's not a vanilla door, you can safely attach a script like this to the door.

 

 

Scriptname ShowMessageOnDoorActivate extends ObjectReference Const

Message Property MessageToShow Auto Const


Event OnInit()
	Utility.Wait(0.5)
	BlockDoor(Block = True)
EndEvent

Event OnLoad()
	BlockDoor(Block = True)
EndEvent

Event OnActivate(ObjectReference akActionRef)
	Actor PlayerRef = Game.GetPlayer()
	; if the door got activated by the player
	If akActionRef == PlayerRef
		; if the door can't be activated however
		If Self.IsActivationBlocked() == True
			Int ButtonIndex = MessageToShow.Show()
			; if the menu button at Index 0 says something like 'Yes, I'd like to travel'
			; script activate the door by the player
			If ButtonIndex == 0
				BlockDoor(Block = False)
				Self.Activate(akActivator = PlayerRef)
				Utility.Wait(0.2)
				BlockDoor(Block = True)
			; otherwise, if the menu button at Index 1 says something like 'Let me think it over'
			ElseIf ButtonIndex == 1
				; do nothing
			; otherwise
			Else
				; do nothing
			EndIf
		Else
			; error, activation should be blocked
		EndIf
	EndIf
EndEvent

Function BlockDoor(bool Block = True)
	If Self.IsActivationBlocked() != Block
		Self.BlockActivation(Block)
	EndIf
EndFunction 

 

I haven't tested it but it should work..

So i got an error message about the last EndIf line "(38,0): missing EndOfFile at 'endif'"

It compiles here. Check that the copy paste didn't mess up the line breaks or any other formatting.

 

Also, unless you already run it, I highly recommend using VS code for Papyrus scripts. The editor inside CK is absolutely terrible and maddening. Notepad++ is not great either but better than CK.

 

There is an excellent syntax extension for papyrus in Vs code called simply "Papyrus", and another for compilation (the first one can probably do that too).

Link to comment
Share on other sites

 

 

If it's not a vanilla door, you can safely attach a script like this to the door.

 

 

Scriptname ShowMessageOnDoorActivate extends ObjectReference Const

Message Property MessageToShow Auto Const


Event OnInit()
	Utility.Wait(0.5)
	BlockDoor(Block = True)
EndEvent

Event OnLoad()
	BlockDoor(Block = True)
EndEvent

Event OnActivate(ObjectReference akActionRef)
	Actor PlayerRef = Game.GetPlayer()
	; if the door got activated by the player
	If akActionRef == PlayerRef
		; if the door can't be activated however
		If Self.IsActivationBlocked() == True
			Int ButtonIndex = MessageToShow.Show()
			; if the menu button at Index 0 says something like 'Yes, I'd like to travel'
			; script activate the door by the player
			If ButtonIndex == 0
				BlockDoor(Block = False)
				Self.Activate(akActivator = PlayerRef)
				Utility.Wait(0.2)
				BlockDoor(Block = True)
			; otherwise, if the menu button at Index 1 says something like 'Let me think it over'
			ElseIf ButtonIndex == 1
				; do nothing
			; otherwise
			Else
				; do nothing
			EndIf
		Else
			; error, activation should be blocked
		EndIf
	EndIf
EndEvent

Function BlockDoor(bool Block = True)
	If Self.IsActivationBlocked() != Block
		Self.BlockActivation(Block)
	EndIf
EndFunction 

 

I haven't tested it but it should work..

So i got an error message about the last EndIf line "(38,0): missing EndOfFile at 'endif'"

It compiles here. Check that the copy paste didn't mess up the line breaks or any other formatting.

 

Also, unless you already run it, I highly recommend using VS code for Papyrus scripts. The editor inside CK is absolutely terrible and maddening. Notepad++ is not great either but better than CK.

 

There is an excellent syntax extension for papyrus in Vs code called simply "Papyrus", and another for compilation (the first one can probably do that too).

 

Not sure what the issue was but I managed to get it working. Thanks for the help everyone!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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