stonefisher Posted June 9, 2017 Share Posted June 9, 2017 Hi, Sorry if this comes out wrong, I have a headache. I need to block an exploit in my mod. I aim to do this by having a script running constantly that looks for when someone enters a barter window. When this happens it whisks away the items into a container and returns them when you leave the barter menu. Dont know if this is a bad way to do it since its running non stop or if there is a better way to block these items from the barter menu. Could someone tell me how to keep the script going. Would duplicate scripts appear and is there anything special i need to put in for uninstalling the mod. Could someone please check out my first bit of code i have ever cobbled together. I have no expectations of it working: Function SomeFunction() RegisterForMenuOpenCloseEvent("BarterMenu") EndFunction Keyword property CaDW_WeaponModMissing auto Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName== "BarterMenu") if (abOpening) Game.GetPlayer().RemoveItem(CaDW_WeaponModMissing, -1, true, CaDW_RPWW_Container) UnregisterForRemoteEvent(asMenuName, "abOpening") endif endif endEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName== "BarterMenu") if (abOpening = False) game.getplayer().addItem(self) CaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer()) UnregisterForRemoteEvent(asMenuName, "abOpening = False") endif endif endEvent Cheers Link to comment Share on other sites More sharing options...
shavkacagarikia Posted June 10, 2017 Share Posted June 10, 2017 Ok, you don't need that unregisters from remote events and that additem as well. Function SomeFunction() RegisterForMenuOpenCloseEvent("BarterMenu")EndFunction Keyword property CaDW_WeaponModMissing auto Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName== "BarterMenu") if (abOpening) Game.GetPlayer().RemoveItem(CaDW_WeaponModMissing, -1, true, CaDW_RPWW_Container) endif endifendEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName== "BarterMenu") if (!abOpening) CaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer()) endif endifendEvent Make sure that someFunction is called from somewhere Link to comment Share on other sites More sharing options...
stonefisher Posted June 10, 2017 Author Share Posted June 10, 2017 hmm, didnt compile: H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Block_Null_Item.psc(1,0): mismatched input 'Function' expecting SCRIPTNAMEH:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Block_Null_Item.psc(0,0): error while attempting to read script CaDW_Block_Null_Item: Object reference not set to an instance of an object.No output generated for CaDW_Block_Null_Item.psc, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on CaDW_Block_Null_Item.psc Link to comment Share on other sites More sharing options...
shavkacagarikia Posted June 10, 2017 Share Posted June 10, 2017 Your script needs name and which form it extends. Link to comment Share on other sites More sharing options...
stonefisher Posted June 10, 2017 Author Share Posted June 10, 2017 Ah ok thx. :) I would have thought it could have got the name from the file. Link to comment Share on other sites More sharing options...
stonefisher Posted June 10, 2017 Author Share Posted June 10, 2017 Papyrus Compiler Version 2.8.0.4 for Fallout 4 Copyright © ZeniMax Media. All rights reserved. Starting 1 compile threads for 1 files... Compiling "CaDW_Block_Null_Item.psc"... H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Block_Null_Item.psc(17,0): script event onmenuopencloseevent already defined in the same state No output generated for CaDW_Block_Null_Item.psc, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on CaDW_Block_Null_Item.psc No idea about this. Link to comment Share on other sites More sharing options...
shavkacagarikia Posted June 10, 2017 Share Posted June 10, 2017 That's true you don't need 2 same events just leave one like this: Function SomeFunction()RegisterForMenuOpenCloseEvent("BarterMenu")EndFunction Keyword property CaDW_WeaponModMissing auto Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)if (asMenuName== "BarterMenu")if (abOpening)Game.GetPlayer().RemoveItem(CaDW_WeaponModMissing, -1, true, CaDW_RPWW_Container)ElseCaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer())endifendifendEvent Link to comment Share on other sites More sharing options...
stonefisher Posted June 10, 2017 Author Share Posted June 10, 2017 Hehe, I dragged my dad into it as well. We whittled it down to this: Scriptname CaDW_Block_Null_Item extends Quest Function SomeFunction() RegisterForMenuOpenCloseEvent("BarterMenu") EndFunction Keyword property CaDW_WeaponModMissing auto ObjectReference property CaDW_RPWW_Container auto Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName== "BarterMenu") if (abOpening) Game.GetPlayer().RemoveItem(CaDW_WeaponModMissing, -1, true, CaDW_RPWW_Container) else CaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer()) endif endif endEvent As after shrinking it down to one event it then complained about the container so we fixed that. Well now it compiles. I added a new quest to my mod to start instantly and to run once with priority 45. I then added the script and filled in the properties. I double cheecked the esp with fo4edit and then launched the game. It dousnt work the items are still there. :/ Link to comment Share on other sites More sharing options...
shavkacagarikia Posted June 10, 2017 Share Posted June 10, 2017 Where are you calling somefunction from? as I said before it wont be called itself. If you want menuopenclose event to be registered when quest is started change that some function with onInit() event. Link to comment Share on other sites More sharing options...
stonefisher Posted June 10, 2017 Author Share Posted June 10, 2017 Ah ok, I will try that. Couldnt find anything about somefunction on the creation kit website. Every single example I could find on the website had Function SomeFunction() so I didnt think it could be changed. Link to comment Share on other sites More sharing options...
Recommended Posts