SkyEmerald Posted August 30, 2017 Share Posted August 30, 2017 Hi there :P I wanted to make a make a safe unlock on the purchase of an item. Say the player buys a collectible model of a robot and after purchasing, a unique safe is permanently opened. I want the chest to be visible and locked before the purchase, so I can't use the initially disabled function. Any ideas guys? Thanks in advance! Link to comment Share on other sites More sharing options...
shavkacagarikia Posted August 30, 2017 Share Posted August 30, 2017 Make a new quest, with run once and start game enabled flags and attach following script to player alias there: Objectreference propety mysaferef autoMiscObject property robotmodel auto Event oninit()Addinventoryeventfilter(robotmodel)Endevent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Mysaferef.unlock() RemoveAllInventoryEventFilters()Endevent Dont forget to fill properties. Link to comment Share on other sites More sharing options...
SkyEmerald Posted August 30, 2017 Author Share Posted August 30, 2017 Make a new quest, with run once and start game enabled flags and attach following script to player alias there: Objectreference propety mysaferef autoMiscObject property robotmodel auto Event oninit()Addinventoryeventfilter(robotmodel)Endevent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)Mysaferef.unlock()RemoveAllInventoryEventFilters()Endevent Dont forget to fill properties. Great! Thanks a lot for this :D I'm moving into making my first quest for the mod so hopefully after a tutorial or two, I can get this quest/script working! Once again, many thanks!!! :) :) Link to comment Share on other sites More sharing options...
JonathanOstrus Posted August 30, 2017 Share Posted August 30, 2017 Make a new quest, with run once and start game enabled flags and attach following script to player alias there: Objectreference propety mysaferef autoMiscObject property robotmodel auto Event oninit()Addinventoryeventfilter(robotmodel)Endevent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)Mysaferef.unlock()RemoveAllInventoryEventFilters()Endevent Dont forget to fill properties. Great! Thanks a lot for this :D I'm moving into making my first quest for the mod so hopefully after a tutorial or two, I can get this quest/script working! Once again, many thanks!!! :smile: :smile: Script has a bug. If you were to transfer the item and it then removes the filter, then it triggers every time an item of any kind is transferred. It would be wise to use a state to ignore further onitemadded events. Link to comment Share on other sites More sharing options...
shavkacagarikia Posted August 30, 2017 Share Posted August 30, 2017 Its filtered for only robotmodel form. So no other added forms should fire onitemadded. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted August 31, 2017 Share Posted August 31, 2017 Its filtered for only robotmodel form. So no other added forms should fire onitemadded. Correct. But in the sample code the OnItemAdded event removes the filter. Which means the next time an item (any) is added it will trigger the event. There's nothing disabling the event. If this script is on a ref alias then clearing the alias would handle that. Arguably that would be the most appropriate way to handle it. Otherwise one would need to make another state (and set it) to override the event and do nothing. Link to comment Share on other sites More sharing options...
shavkacagarikia Posted August 31, 2017 Share Posted August 31, 2017 My bad. Yes, you are right. self.clear() instead of removing inventory filters and alias needs to be set as optional. Link to comment Share on other sites More sharing options...
Recommended Posts