Jump to content

RemoveItem not working, and neither is Additem through formlist :(


xcafe

Recommended Posts

So I'm trying to have a formlist of armor added to the player, but it's not working. Here's the code:

             Int ListSize = O3.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = O3.GetAt(Index)
    If (Entry as Armor)
        PlayerRef.RemoveItem(Entry as Armor, Self)

And it gives me this error: C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\outfitmanager.psc(168,18): type mismatch on parameter 2 (did you forget a cast?)

But the script is attached to a Wardrobe, so it should be able to use the self variable for that function!
And it actually recognizes self when I do this:
      Int ListSize = O3.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = O3.GetAt(Index)
    If (Entry as Armor)
        PlayerRef.RemoveItem(Entry as Armor)
        Self.AddItem(Entry as Armor)
  EndIf   
  EndWhile

But then it A. only removes one armor piece at a time (I want it to remove all of them in one go) and B. adds an infinite amount of the item to the wardrobe.

 

 

 

The script that I have to add the items BACK to the player from the wardrobe also adds an infinite amount:

   Int ListSize = O1.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = O1.GetAt(Index)
    If (Entry as Armor)
        PlayerRef.AddItem(Entry as Armor)
  EndIf   
  EndWhile      

Help please?

 

Link to comment
Share on other sites

The reason they are 'infinite' is that you are not increasing the Index variable in order to advance to the next entry in the formlist.

 

As far as the one that isn't recognizing the Self variable... RemoveItem has four parameters which the last three have default values which means you can simply do

PlayerRef.RemoveItem(SomeItem)

and it will work. However, if you wish to override one of the three parameters with something else, you also have to include a value for any parameters in between. In this case you want to override the akOtherContainer parameter. You would need

PlayerRef.RemoveItem(SomeItem,1,false,SomeContainer)

Note that the in between parameters are still given their default values.

 

 

After saying all that, it should be noted that you can use a formlist directly in the RemoveItem function. And with a little thinking you can use RemoveItem to move items in the reverse direction if need be (provided of course that the items were removed to a valid container originally).

Link to comment
Share on other sites

No dice, it still gives me an error.

PlayerRef.RemoveItem((PlayerRef.GetWornForm(0x80000000) as Armor),1,false,Self)
C:\Program Files (x86)\Steam\steamapps\common\Skyrim\Data\scripts\source\outfitmanager.psc(165,18): type mismatch on parameter 2 (did you forget a cast?)
Link to comment
Share on other sites

I thought you were trying to remove items from the player that were stored in a formlist. Now you are trying to remove an item obtained with GetWornForm? Move the GetWornForm outside of RemoveItem. Might help it to work better. Also, make sure that that is indeed the line which the compiler is complaining about. The numbers tell you which line and which character column the error is at. In this latest case, line 165, column 18.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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