Jump to content

Script help - detect when a player uses a workbench


cenarius451

Recommended Posts

I'm trying to detect whenever a player uses a workbench, the armor one in particular. I've been trying the following script:

Event OnInit()
	RegisterForTutorialEvent("ArmorWorkbenchEntered")
	RegisterForTutorialEvent("ArmorWorkbenchExited")
EndEvent

Event OnTutorialEvent(String asEventName, Message aMessage)
	If asEventName == "ArmorWorkbenchEntered"
		rep_IsInMenu.SetValueInt(1)
		debug.Notification("I'm in an armor workbench!")
	ElseIf asEventName == "ArmorWorkbenchExited"
		rep_IsInMenu.SetValueInt(0)
		debug.Notification("I'm out of an armor workbench!")
	EndIf
	RegisterForTutorialEvent("ArmorWorkbenchEntered")
	RegisterForTutorialEvent("ArmorWorkbenchExited")
EndEvent

This compiles but it doesn't trigger ingame. My idea is to set a global variable to check when the player is in a workbench mode (or menu as i imagined it at first). Couldn't find a better way of doing this but to try the tutorial thing, don't know if it's the correct approach.

 

Please help me to solve this, i refuse to believe there is no way through a script to detect a player when he uses a workbench. Any ideas will be appreciated.

Edited by cenarius451
Link to comment
Share on other sites

Here you go:

 

 

 

ScriptName YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()

        Actor PlayerRef = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerRef, "OnSit")	
	RegisterForRemoteEvent(PlayerRef, "OnGetUp")
	
EndEvent

Event Actor.OnSit(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player entered an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(1)
	EndIf

EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player exited an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(0)
	EndIf

EndEvent

 

 

OnSit and OnGetUp events are receieved when the enter/exit workbench animations finish. Does not require F4SE.

 

 

 

Scriptname YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndEvent

Function Initialize()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndFunction

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "ExamineMenu"
		Actor PlayerRef = Game.GetPlayer()
		ObjectReference FurnitureRef = PlayerRef.GetFurnitureReference()
		If PlayerRef.GetSitState() != 0 && FurnitureRef.HasKeyword(WorkbenchArmor)
			If abOpening == true
				Debug.MessageBox("Player entered an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(1)
			Else
				Debug.MessageBox("Player exited an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(0)
			EndIf
		EndIf
	EndIf
EndEvent

 

 

OnMenuOpenCloseEvent is recieved when the menu opens/closes (of course) so slightly after the enter/exit workbench animations start. Requires F4SE.

 

Edited the first script.. I forgot to add the WorkbenchArmor condition to it :smile:

Edited by LarannKiar
Link to comment
Share on other sites

T

 

Here you go:

 

 

 

ScriptName YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()

        Actor PlayerRef = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerRef, "OnSit")	
	RegisterForRemoteEvent(PlayerRef, "OnGetUp")
	
EndEvent

Event Actor.OnSit(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player entered an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(1)
	EndIf

EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player exited an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(0)
	EndIf

EndEvent

 

 

OnSit and OnGetUp events are receieved when the enter/exit workbench animations finish. Does not require F4SE.

 

 

 

Scriptname YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndEvent

Function Initialize()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndFunction

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "ExamineMenu"
		Actor PlayerRef = Game.GetPlayer()
		ObjectReference FurnitureRef = PlayerRef.GetFurnitureReference()
		If PlayerRef.GetSitState() != 0 && FurnitureRef.HasKeyword(WorkbenchArmor)
			If abOpening == true
				Debug.MessageBox("Player entered an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(1)
			Else
				Debug.MessageBox("Player exited an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(0)
			EndIf
		EndIf
	EndIf
EndEvent

 

 

OnMenuOpenCloseEvent is recieved when the menu opens/closes (of course) so slightly after the enter/exit workbench animations start. Requires F4SE.

 

Edited the first script.. I forgot to add the WorkbenchArmor condition to it :smile:

Thank you for your reply. Unfortunately none of the methods worked. I guess that's it uh? it wouldn't be the first time a function seems bugged in the CK, same happened with another script i made where i was spossed to detect if the player is moving and the function only detects when the player moves forward, not backwards or strafing left/right, or another when detecting if the player is in first person or third person, the function just doesnt work, period. A shame.

Link to comment
Share on other sites

T

 

Here you go:

 

 

 

ScriptName YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()

        Actor PlayerRef = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerRef, "OnSit")	
	RegisterForRemoteEvent(PlayerRef, "OnGetUp")
	
EndEvent

Event Actor.OnSit(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player entered an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(1)
	EndIf

EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player exited an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(0)
	EndIf

EndEvent

 

 

OnSit and OnGetUp events are receieved when the enter/exit workbench animations finish. Does not require F4SE.

 

 

 

Scriptname YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndEvent

Function Initialize()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndFunction

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "ExamineMenu"
		Actor PlayerRef = Game.GetPlayer()
		ObjectReference FurnitureRef = PlayerRef.GetFurnitureReference()
		If PlayerRef.GetSitState() != 0 && FurnitureRef.HasKeyword(WorkbenchArmor)
			If abOpening == true
				Debug.MessageBox("Player entered an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(1)
			Else
				Debug.MessageBox("Player exited an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(0)
			EndIf
		EndIf
	EndIf
EndEvent

 

 

OnMenuOpenCloseEvent is recieved when the menu opens/closes (of course) so slightly after the enter/exit workbench animations start. Requires F4SE.

 

Edited the first script.. I forgot to add the WorkbenchArmor condition to it :smile:

Thank you for your reply. Unfortunately none of the methods worked. I guess that's it uh? it wouldn't be the first time a function seems bugged in the CK, same happened with another script i made where i was spossed to detect if the player is moving and the function only detects when the player moves forward, not backwards or strafing left/right, or another when detecting if the player is in first person or third person, the function just doesnt work, period. A shame.

 

Stop and start your quest the script is / scripts are attached to (see OnQuestInit). Make sure the "Run once" flag is unchecked (Quest Data tab).

Link to comment
Share on other sites

 

T

 

Here you go:

 

 

 

ScriptName YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()

        Actor PlayerRef = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerRef, "OnSit")	
	RegisterForRemoteEvent(PlayerRef, "OnGetUp")
	
EndEvent

Event Actor.OnSit(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player entered an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(1)
	EndIf

EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player exited an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(0)
	EndIf

EndEvent

 

 

OnSit and OnGetUp events are receieved when the enter/exit workbench animations finish. Does not require F4SE.

 

 

 

Scriptname YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndEvent

Function Initialize()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndFunction

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "ExamineMenu"
		Actor PlayerRef = Game.GetPlayer()
		ObjectReference FurnitureRef = PlayerRef.GetFurnitureReference()
		If PlayerRef.GetSitState() != 0 && FurnitureRef.HasKeyword(WorkbenchArmor)
			If abOpening == true
				Debug.MessageBox("Player entered an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(1)
			Else
				Debug.MessageBox("Player exited an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(0)
			EndIf
		EndIf
	EndIf
EndEvent

 

 

OnMenuOpenCloseEvent is recieved when the menu opens/closes (of course) so slightly after the enter/exit workbench animations start. Requires F4SE.

 

Edited the first script.. I forgot to add the WorkbenchArmor condition to it :smile:

Thank you for your reply. Unfortunately none of the methods worked. I guess that's it uh? it wouldn't be the first time a function seems bugged in the CK, same happened with another script i made where i was spossed to detect if the player is moving and the function only detects when the player moves forward, not backwards or strafing left/right, or another when detecting if the player is in first person or third person, the function just doesnt work, period. A shame.

 

Stop and start your quest the script is / scripts are attached to (see OnQuestInit). Make sure the "Run once" flag is unchecked (Quest Data tab).

 

I got this error message when compiling: new event onquestinit cannot be defined because the script is not flagged as native

I add the native flag on the sctipt and get tons of errors.

 

I give up. Again, thank you for your reply.

Link to comment
Share on other sites

 

 

T

 

Here you go:

 

 

 

ScriptName YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()

        Actor PlayerRef = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerRef, "OnSit")	
	RegisterForRemoteEvent(PlayerRef, "OnGetUp")
	
EndEvent

Event Actor.OnSit(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player entered an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(1)
	EndIf

EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)

	If akFurniture.HasKeyword(WorkbenchArmor)
		Debug.MessageBox("Player exited an Armor Workbench")
		IsPlayerUsingArmorWorkbench.SetValueInt(0)
	EndIf

EndEvent

 

 

OnSit and OnGetUp events are receieved when the enter/exit workbench animations finish. Does not require F4SE.

 

 

 

Scriptname YOURSCRIPTNAME extends Quest Const

Keyword Property WorkbenchArmor Auto Const
Globalvariable Property IsPlayerUsingArmorWorkbench Auto Const


Event OnQuestInit()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndEvent

Function Initialize()
	RegisterForMenuOpenCloseEvent("ExamineMenu")
EndFunction

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	If asMenuName == "ExamineMenu"
		Actor PlayerRef = Game.GetPlayer()
		ObjectReference FurnitureRef = PlayerRef.GetFurnitureReference()
		If PlayerRef.GetSitState() != 0 && FurnitureRef.HasKeyword(WorkbenchArmor)
			If abOpening == true
				Debug.MessageBox("Player entered an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(1)
			Else
				Debug.MessageBox("Player exited an Armor Workbench")
				IsPlayerUsingArmorWorkbench.SetValueInt(0)
			EndIf
		EndIf
	EndIf
EndEvent

 

 

OnMenuOpenCloseEvent is recieved when the menu opens/closes (of course) so slightly after the enter/exit workbench animations start. Requires F4SE.

 

Edited the first script.. I forgot to add the WorkbenchArmor condition to it :smile:

Thank you for your reply. Unfortunately none of the methods worked. I guess that's it uh? it wouldn't be the first time a function seems bugged in the CK, same happened with another script i made where i was spossed to detect if the player is moving and the function only detects when the player moves forward, not backwards or strafing left/right, or another when detecting if the player is in first person or third person, the function just doesnt work, period. A shame.

 

Stop and start your quest the script is / scripts are attached to (see OnQuestInit). Make sure the "Run once" flag is unchecked (Quest Data tab).

 

I got this error message when compiling: new event onquestinit cannot be defined because the script is not flagged as native

I add the native flag on the sctipt and get tons of errors.

 

I give up. Again, thank you for your reply.

 

 

Replace OnQuestInit() with OnInit() if you didn't attach the script to a Quest.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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