Thread Tools Display Modes
08/27/23, 04:36 AM   #1
schorse
Join Date: Aug 2023
Posts: 4
SellInventoryItem() doesn't sell some items

Hi,

I was trying to sell my whole inventory and the function SellInventoryItem() fails to do so in most cases.

My inventory consists of:
1 x Platinum Necklace (Ornate)
1 x Common Repair Kit
20 x Grand Repair Kit
1 x Recipe: Fredas Night Infusion
34 x Soul Gem (Empty)
1 x Superb Glyph of Health Recovery
1 x Rubedo Leather Jack (Intricate)

While interacting with a merchant i run the following code:
Code:
	SLASH_COMMANDS["/sellall"] = function()
		local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil,BAG_BACKPACK)
		
		for bagSlot in pairs(bagCache) do
			SellInventoryItem(BAG_BACKPACK, bagSlot, bagCache[bagSlot].stackCount)
		end
	end
After that only the Common Repair kit and the Recipe are sold. If I split the the Grand Repair Kits to 19 - 1 it works somehow for the 1 Kit. Does someone have experience with autoselling and knows what I am doing wrong here?

Thanks for answers!
  Reply With Quote
08/28/23, 02:10 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I guess the function SellInventoryItem will stop to work if you try to pass in a non-sellable one?

GenerateFullSlotData returns a table bagCache and you should check which items are in there, I guess all inventoty items as you did not specify any filterunction as 1st param!

So maybe you need to stay with using GenerateFullSlotData BUT specify a filterfunction as 1st param which filters non-sellable items.
There should exist a function which returns that info, by checking item's price == 0 e.g.
According to ZOs all non sellable ones will be 0 gold cost meanwhile (current patch notes).

Check if you can use this function:
CanSellItem(inventorySlot)

I hope the inventorySlot is the data (see below) table here.



Edit:
After checking my code I'm using

Code:
for _, data in pairs(bagCache) do
local bagId = data.bagId
local slotIndex = data.slotIndex
instead of using the _ as bagSlot (slotIndex) like in your code above.
Maybe they are the same though so might not have any impact, can be used either way?

Last edited by Baertram : 08/28/23 at 02:22 AM.
  Reply With Quote
08/29/23, 12:33 AM   #3
schorse
Join Date: Aug 2023
Posts: 4
Hey thanks for the answer. The items in my inventory at that time were all sellable. I was able to do it manually and buy them back.

After trying another day everything works how I want it to. Maybe because of restarting ESO? It's a little unsatisfying but I'll take it.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » SellInventoryItem() doesn't sell some items


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off