• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Sell all bug?

Skuter

New Member
Joined
Oct 4, 2017
Messages
12
Reaction score
2
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
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"}
}
And when I want to sell MPAs it sells whole backpack
 
Back
Top