Hello, I'm using TFS 0.3.6 example trader template, but I have problem with sell all while ignore equipped is unchecked
Here is buy/sell part of code
And the item table:
And when I want to sell MPAs it sells whole backpack
Here is buy/sell part of code
Lua:
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if(items[item] == nil) then
selfSay("Ehm.. sorry... this shouldn't be there, I'm not selling it.", cid)
return
end
if(getPlayerMoney(cid) >= amount * items[item].buyPrice) then
local itemz, i = doNpcSellItem(cid, item, amount, subType, ignoreCap, inBackpacks)
if(i < amount) then
if(i == 0) then
selfSay("Sorry, but you don't have space to take it.", cid)
else
selfSay("I've sold some for you, but it seems you can't carry more than this. I won't take more money than necessary.", cid)
doPlayerRemoveMoney(cid, i * items[item].buyPrice)
end
else
selfSay("Thanks for the money!", cid)
doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
end
else
selfSay("Stfu noob, you don't have money.", cid)
end
end
local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if(items[item] == nil) then
selfSay("Ehm.. sorry... this shouldn't be there, I'm not buying it.", cid)
end
if(subType < 1) then
subType = -1
end
if(doPlayerRemoveItem(cid, item, amount, subType)) then
doPlayerAddMoney(cid, items[item].sellPrice * amount)
selfSay("Here you are.", cid)
else
selfSay("No item, no deal.", cid)
end
end
And the item table:
Lua:
local itemWindow = {
{id=1988, subType=0, buy=10, sell=0, name="bagpack"},
{id=12746, subType=0, buy=10000, sell=0, name="AOL"},
{id=2265, subType=0, buy=10, sell=0, name="medicine"},
{id=2273, subType=0, buy=100, sell=0, name="ultimate healing"},
{id=3366, subType=0, buy=0, sell=10000, name="Magic Plate Armor"}
}