Yrdolf Posted December 26, 2012 Share Posted December 26, 2012 Hi everyone I have a problem with my script that sould work like the archmage chest of Oblivion.Every time I want to compile it the CK says "AddItem is not a function or does not exist".I've tried to let the Items move into the players inventory by using "Game.GetPlayer()" and this works but if I use "Chest" it says it is not a function.Here it is: ;PropertysContainer Property Chest Auto ;FunctionsFunction AddItem(Form akItemToAdd, int aiCount = 1, bool abSilent = false) nativeFunction WaitGameTime(float afHours) native global Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)Utility.WaitGameTime(24); Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false)Chest.AddItem(akBaseItem, aiItemCount, true)Utility.WaitGameTime(168)EndEvent I can't find my fault. I hope anyone else can help me. Link to comment Share on other sites More sharing options...
TheSkoomaKing Posted December 26, 2012 Share Posted December 26, 2012 ;Propertys Container Property Chest Auto ;Functions Function AddItem(Form akItemToAdd, int aiCount = 1, bool abSilent = false) native Function WaitGameTime(float afHours) native global Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Utility.WaitGameTime(24) ; Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false) Chest.AddItem(akBaseItem, aiItemCount, true) Utility.WaitGameTime(168) EndEvent Im not a master myself, but i think the chest property is unseen by the fuction. Try adding Chest = akSourceContainer do not know if it works but had a similar problem once and that solved it! Link to comment Share on other sites More sharing options...
Yrdolf Posted December 26, 2012 Author Share Posted December 26, 2012 Thanks for the fast reply I've added it under my Chest Property but it does not work. A new error appears (No viable alternate at input "=") Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 26, 2012 Share Posted December 26, 2012 What exactly are you trying to accomplish? I'm not familiar with Oblivion but have done several scripts regarding containers and transfering items for Skyrim. I may have something lying about that could be easily adapted. Just need to know exactly what you are wanting to do. Link to comment Share on other sites More sharing options...
ArthasTheGreat Posted December 27, 2012 Share Posted December 27, 2012 Archmages chest works like this :You put in some plant (nirinroot)And in 24 h you will find 10 nirinroots In the chest It works with any ingridient Link to comment Share on other sites More sharing options...
steve40 Posted December 27, 2012 Share Posted December 27, 2012 (edited) 1) do not declare native functions2) the chest must be an ObjectReference. You cannot add items to the base Container formTip: if you are putting this script on your chest, then you don't even need the chest property at all (self == chest). ScriptName AddItemTest extends ObjectReference ;Properties ObjectReference Property Chest Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Utility.WaitGameTime(24) ; Game.GetPlayer().AddItem(akBaseItem, aiItemCount, false) Chest.AddItem(akBaseItem, aiItemCount, true) ; Utility.WaitGameTime(168) ; this line is redundant, it serves no purpose? EndEvent Question: what would happen if you add an item to the chest, then immediately after, add a different item to the chest? Would only the last item get multiplied after 24 hours? Edited December 27, 2012 by steve40 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 27, 2012 Share Posted December 27, 2012 Archmages chest works like this :You put in some plant (nirinroot)And in 24 h you will find 10 nirinroots In the chest It works with any ingridientHmm ok. steve40's suggestion should allow the script to compile. As it appears tho it would perform the task on any item, not just ingredients. You may want to consider looking at this example script on the wiki to see how it causes a container to only accept certain items: http://www.creationkit.com/Complete_Example_Scripts#Script_a_container_that_only_accepts_certain_types_of_items Link to comment Share on other sites More sharing options...
steve40 Posted December 27, 2012 Share Posted December 27, 2012 (edited) @IsharaMeradin: I was just getting around to that :) ScriptName AddItemTest extends ObjectReference Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Ingredient BlockActivation() ; don't allow any more ingredients to be added or removed Utility.WaitGameTime(24) AddItem(akBaseItem, aiItemCount, true) BlockActivation(false) ; can now add more ingredients or remove items from container Else RemoveItem(akBaseItem, aiItemCount, true, akSourceContainer) ; if it is not an ingredient, return it to the player EndIf EndEvent Edited December 27, 2012 by steve40 Link to comment Share on other sites More sharing options...
Yrdolf Posted December 27, 2012 Author Share Posted December 27, 2012 Thanks for your replys. I tried some of your solutions.The ObjectReference Property works, now the script can compile, the "Ingredient Filter" works and the BlockActivation too.But now, if I place Items in that Chest, they will not duplicate. Before in my Script above the Item that was added to the Chest was Duplicated as many times as it was added (For example, i've added 2 Wheat and after 24 hours the Chest had 4 Wheat)And the second problem is, that the Chest will not stop to Block but i've told it to stop blocking after the 24 hours. Scriptname duplicateItem extends ObjectReference {Duplicates an Item in a chest.} ;Propertys ObjectReference Property Chest Auto ;Functions Function AddItem(Form akItemToAdd, int aiCount = 1, bool abSilent = false) native Function WaitGameTime(float afHours) native global ;Events, If the player adds an Item to the chest, it will be duplicated after 24 hours and you can do this again after 168 hours (one week) Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if akBaseItem as Ingredient BlockActivation() Utility.WaitGameTime(24) Chest.AddItem(akBaseItem, aiItemCount, true) BlockActivation(false) Else RemoveItem(akBaseItem, aiItemCount, true, akSourceContainer) ; if it is not an ingredient, return it to the player EndIf EndEvent Link to comment Share on other sites More sharing options...
MShoap13 Posted December 27, 2012 Share Posted December 27, 2012 (edited) Function AddItem(Form akItemToAdd, int aiCount = 1, bool abSilent = false) native Is it just me or does this line look a little funny? :tongue: Edited December 27, 2012 by MShoap13 Link to comment Share on other sites More sharing options...
Recommended Posts