Plastrader Posted January 14, 2013 Share Posted January 14, 2013 I've tried to find anything on these boards that explains this but I can't.And now after too many* hours of "trial and error" I give up... RemoveAllItems - ObjectReferenceFunction RemoveAllItems(ObjectReference akTransferTo = None, bool abKeepOwnership = false, bool abRemoveQuestItems = false) native However I can't seem to get the items transfered to my inventory. ObjectReference Property pPlayerRef Auto ;This points to Cell: Any, Reference: PlayerRef('Player') Function someFuntion() NPCReference.RemoveAllItems(MyPlayerRef, false, false) EndFunction NPC is cleared but items doesn't show up in my inventory, same goes with:NPCReference.RemoveAllItems(Game.GetPlayer(), false, false) I've tried changing the player reference to about every possible property but to no avail... I also tried with a container ObjectReference Property pEmptyBarrel Auto ;This points to Cell: where the barrel is at, Reference: id of barrel Function someFuntion() NPCReference.RemoveAllItems(pEmptyBarrel, false, false) EndFunction This barrel has the following script attached to it: Scriptname Script_ContainerItems extends ObjectReference Event OnInit() Debug.Notification("I AM VERY ANGRY!!!") EndEvent Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) debug.trace(self + " akNewContainer :" + akNewContainer + "\n") debug.trace(self + " akOldContainer :" + akOldContainer + "\n") EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) debug.trace(self + " akBaseItem:" + akBaseItem + "\n") debug.trace(self + " aiItemCount:" + aiItemCount + "\n") debug.trace(self + " akItemReference:" + akItemReference + "\n") debug.trace(self + " akSourceContainer:" + akSourceContainer + "\n") EndEvent The "I AM VERY ANGRY!!!" text is displayed but nothing shows in the script logs.(Script logs are set to max.) And another question I have regarding scripts.The properties you set in the UI where you point out the references where are they stored?I'm guessing those are compiled to the .pex but I don't know for sure. So if anyone could help me out here I'd be very happy and grateful! *About 11+ hrs actually... Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 15, 2013 Share Posted January 15, 2013 The big questions... Where is the script assigned? Is it an object or an actor?When is the transfer supposed to happen? During a specific event? Knowing some of this stuff might help others to help you get going in the correct direction. The properties you set in the UI where you point out the references where are they stored?Are you referring to the properties you assign in the CK after compiling a script? They are stored on that particular record form in the ESP and then get stored in your save game on any references to that form. Thus if you apply a script to a stock object, after your mod is removed there will be at minimum some warnings about missing properties etc.. But this does give the added benefit of using the same script on multiple objects with different property values. Link to comment Share on other sites More sharing options...
Plastrader Posted January 15, 2013 Author Share Posted January 15, 2013 what you wrote. I'm sorry in my frustration I forgot the obvious... The script is assigned to a quest.ScriptName <name of script> extends Quest Conditional. Thanks for the enlightenment about the properties.And yes those were the once I was thinking of, Link to comment Share on other sites More sharing options...
Eckss Posted January 15, 2013 Share Posted January 15, 2013 (edited) You haven't declared either of your variables in the function declaration. Change this: Function someFuntion() NPCReference.RemoveAllItems(MyPlayerRef, false, false) EndFunction To something like this: Function someFuntion(Actor NPCReference, Actor MyPlayerRef) NPCReference.RemoveAllItems(MyPlayerRef, false, false) EndFunction I also recommend declaring the PlayerRef property as an Actor not an ObjectReference. Improper property declarations will compile, but they don't work well. P.S. Thanks IsharaMeradin, that extra info helped. ;) Edited January 15, 2013 by Eckss Link to comment Share on other sites More sharing options...
Plastrader Posted January 15, 2013 Author Share Posted January 15, 2013 You haven't declared either of your variables in the function declaration. Change this: Function someFuntion() NPCReference.RemoveAllItems(MyPlayerRef, false, false) EndFunction To something like this: Function someFuntion(Actor NPCReference, Actor MyPlayerRef) NPCReference.RemoveAllItems(MyPlayerRef, false, false) EndFunction If I ever wrote something in a thread that I wanted help with I really failed this time, my apologies :/Actually my function look like this:(I was copy pasting the wrong function when I created the thread...) Function someFunction(ObjectReference NPCReference, Actor NPCActor) ;This as I tried with both reference and actor for the NPC NPCReference.RemoveAllItems(pPlayerRef, false, false) ;NPCActor.RemoveAllItems(pPlayerRef, false, false) ;This only removed weapons not the gear. EndFunction I also recommend declaring the PlayerRef property as an Actor not an ObjectReference. Improper property declarations will compile, but they don't work well.Wouldn't changing the PlayerRef property to Actor be the same as:NPCReference.RemoveAllItems(Game.GetPlayer(), false, false)As according to GetPlayer - GameGame.GetPlayer() returns ActorThis didn't work either as I mentioned but I'll try changing the property and get back with the results. Thanks to both of you for helping me out! :) Link to comment Share on other sites More sharing options...
Eckss Posted January 15, 2013 Share Posted January 15, 2013 If I ever wrote something in a thread that I wanted help with I really failed this time, my apologies :/Actually my function look like this:(I was copy pasting the wrong function when I created the thread...) Function someFunction(ObjectReference NPCReference, Actor NPCActor) ;This as I tried with both reference and actor for the NPC NPCReference.RemoveAllItems(pPlayerRef, false, false) ;NPCActor.RemoveAllItems(pPlayerRef, false, false) ;This only removed weapons not the gear. EndFunction In future, please read my whole reply. In this function, you still haven't passed in your pPlayerRef variable. That's why the player never receives the items. If you want to strip the NPC, you have to use NPCActor.UnEquipAll () first. Use Actor for both NPC & Player, it's more efficient. Wouldn't changing the PlayerRef property to Actor be the same as:NPCReference.RemoveAllItems(Game.GetPlayer(), false, false)No, it wouldn't. Game.GetPlayer doesn't play well with RemoveAllItems (Or a lot of other functions for that matter) and it's a bad idea to use it anyway as it's VERY inefficient and inefficient scripts add to game instability. So, to conclude, use: Function someFunction(Actor NPCActor, Actor pPlayerRef) NPCActor.UnEquipAll () NPCActor.RemoveAllItems(pPlayerRef) EndFunction Link to comment Share on other sites More sharing options...
Plastrader Posted January 15, 2013 Author Share Posted January 15, 2013 In future, please read my whole reply. In this function, you still haven't passed in your pPlayerRef variable. That's why the player never receives the items. If you want to strip the NPC, you have to use NPCActor.UnEquipAll () first. Use Actor for both NPC & Player, it's more efficient.I did!But I thought that my property declaration would be a variable that was visible for the whole script...And yes I was to change the ObjectReference to Actor as suggested. No, it wouldn't. Game.GetPlayer doesn't play well with RemoveAllItems (Or a lot of other functions for that matter) and it's a bad idea to use it anyway as it's VERY inefficient and inefficient scripts add to game instability.Ye, I read that this method was inefficent aswell.So basically the wiki function return value is invalid then, thats great!!So, to conclude, use: Function someFunction(Actor NPCActor, Actor pPlayerRef) NPCActor.UnEquipAll () NPCActor.RemoveAllItems(pPlayerRef) EndFunction Right I'll try that, thank you. Link to comment Share on other sites More sharing options...
Eckss Posted January 15, 2013 Share Posted January 15, 2013 But I thought that my property declaration would be a variable that was visible for the whole script...Easy mistake to make; I made it myself based on what was written in the Wiki & had to work this out myself. Functions need to be completely self-contained, even within the script they're declared in and even if they're never called from outside that script. Ye, I read that this method was inefficent aswell.So basically the wiki function return value is invalid then, thats great!!It's actually a problem with timing; papyrus scripts all run simultaneously, switching processing between each other with each function call. When you call Game.GetPlayer(), it does return the correct value, it just doesn't do it quickly enough for many of the functions you'd want to use it with. It's a bad idea for efficiency, but this would work: Function someFunction(Actor NPCActor) NPCActor.UnEquipAll () Actor akPlayer = Game.GetPlayer () NPCActor.RemoveAllItems(akPlayer) EndFunctionRight I'll try that, thank you. Good, you're welcome.:) Link to comment Share on other sites More sharing options...
Plastrader Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) Good, you're welcome.:)Hi again, sorry for not responding. I was trying to make this work as I wanted, but noticed I was doing something fundamentally wrong... I was editing the vanilla scripts...Something I noticed other mods were doing too and I want to aviod that. Stuck message: So I was to try adding a dialogue to the NPC.After being bashed in the head by the "quest dialogue"-bug which I managed to dodge after a while I ran into another problem.When I selected my dialogue I was teleported to The Thieves guild...I've disected other dialogues and made my dialogue the same way.I even did the tutorial quest from the wiki, it doesn't work either as I'm teleported away from my current location... A few days ago I found: Extending Scripts so I thought I have a closer look at it.However that doesn't seem to work, or atleast I can't.I have extended the script.The CK acknowledge my inherited script by auto adding the properties.The compiler complains over me adding events and functions with arguments which aren't in the parent script.But!Over riding the functions doesn't work! :(And on top of that neither of the events are triggered from the parent quest.(I added all of them from Quest Script:Events So basically I haven't managed to find a way to test your suggestions in a "safe" way.Whilst getting overly frustrated with trial and erroroing and that I can't get anything to work I have to admit I'm stuck... :( I'm unstuck, please read next post. Edited January 21, 2013 by Plastrader Link to comment Share on other sites More sharing options...
Recommended Posts