PDA

View Full Version : Self.ShopSellAllItems problem



Christian Peres
07-09-2016, 06:44 PM
When I use the line: Self.ShopSellAllItems("royal helmet")
this happens
https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/13645337_1835219163375951_1992889196294444657_n.jp g?oh=bde7ccb440daad38aecd6f3e5d69e39d&oe=58001423&__gda__=1476274249_3a8969593a8c65602dac91909f88c8b 7

acrozo01
07-09-2016, 08:43 PM
From what I know It's by ID.
But you can do it like this as well : Self.ShopSellAllItems(Item.GetID("Royal Helmet"))

shadowart
07-09-2016, 11:26 PM
ID or name doesn't matter.

What's happening is that you're trying to sell an item that you have equipped. There is a bug in the way the bot counts the number of sellable items, so you have to manually deduct the number of equipped items of the kind you're trying to sell. Use this custom lua code instead of the built in Self.ShopSellAllItems:


local function countInEquipment(item)
local count = 0

local id = Item.GetItemIDFromDualInput(item)
local slots = {Self.Head, Self.Armor, Self.Legs, Self.Feet, Self.Amulet, Self.Weapon, Self.Ring, Self.Shield, Self.Ammo}
for i = 1, #slots do
local slot = slots[i]()
if (slot.id == id) then
count = count + math.max(slot.count, 1)
end
end

return count
end

function Self.ShopSellAllItemsFixed(item)
local count = countInEquipment(item)
while Self.ShopGetItemSaleCount(item) - count > 0 do
Self.ShopSellItem(item, Self.ShopGetItemSaleCount(item) - count)
end
return 1, 0
end

Christian Peres
07-12-2016, 03:13 PM
Dude, thanks a lot!!