Jump to content

Code check and how do I keep it running?


Recommended Posts

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

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

endif

endEvent

 

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)

if (asMenuName== "BarterMenu")

if (!abOpening)

CaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer())

endif

endif

endEvent

 

Make sure that someFunction is called from somewhere

Link to comment
Share on other sites

hmm, didnt compile:

 

H:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Source\User\CaDW_Block_Null_Item.psc(1,0): mismatched input 'Function' expecting SCRIPTNAME
H:\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

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

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)

Else

CaDW_RPWW_Container.RemoveItem(CaDW_WeaponModMissing, -1, true, game.getplayer())

endif

endif

endEvent

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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