cenarius451 Posted May 13, 2022 Share Posted May 13, 2022 (edited) 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 May 13, 2022 by cenarius451 Link to comment Share on other sites More sharing options...
Zorkaz Posted May 13, 2022 Share Posted May 13, 2022 Don't wanna be this guy but better repost it here:Man I wish I could script ropes, then this would be possible Link to comment Share on other sites More sharing options...
LarannKiar Posted May 13, 2022 Share Posted May 13, 2022 (edited) 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 May 13, 2022 by LarannKiar Link to comment Share on other sites More sharing options...
cenarius451 Posted May 14, 2022 Author Share Posted May 14, 2022 Don't wanna be this guy but better repost it here:Man I wish I could script ropes, then this would be possibleWhere should i post this then? Link to comment Share on other sites More sharing options...
cenarius451 Posted May 14, 2022 Author Share Posted May 14, 2022 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 More sharing options...
LarannKiar Posted May 14, 2022 Share Posted May 14, 2022 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 More sharing options...
Zorkaz Posted May 14, 2022 Share Posted May 14, 2022 Lol I meant here, wrong copy and pastehttps://forums.nexusmods.com/index.php?/forum/3935-fallout-4-creation-kit-and-modders/ Link to comment Share on other sites More sharing options...
cenarius451 Posted May 15, 2022 Author Share Posted May 15, 2022 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 nativeI 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 More sharing options...
LarannKiar Posted May 15, 2022 Share Posted May 15, 2022 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 nativeI 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 More sharing options...
Recommended Posts