• 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!

TFS [tibia 8.0] cannot buy more than 100 items?

woeterman94

Inventor
Joined
Oct 2, 2008
Messages
84
Reaction score
6
Location
Belgium
I'm using Ninjalulz TFS tibia 8.0 branch. And it seems that npcs cannot sell more than 100 items? Anyone an idea on how to fix this?

My donpcsellitem looks like this.

Lua:
function doNpcSellItem(cid, itemId, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 0
    local item = 0
    local player = Player(cid)
    if ItemType(itemId):isStackable() then
        local stuff
        if inBackpacks then
            stuff = Game.createItem(backpack, 1)
            item = stuff:addItem(itemId, math.min(100, amount))
        else
            stuff = Game.createItem(itemId, math.min(100, amount))
        end


        return player:addItemEx(stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
    end


    local a = 0
    if inBackpacks then
        local container, itemType, b = Game.createItem(backpack, 1), ItemType(backpack), 1
        for i = 1, amount do
            local item = container:addItem(itemId, subType)
            if isInArray({(itemType:getCapacity() * b), amount}, i) then
                if player:addItemEx(container, ignoreCap) ~= RETURNVALUE_NOERROR then
                    b = b - 1
                    break
                end


                a = i
                if amount > i then
                    container = Game.createItem(backpack, 1)
                    b = b + 1
                end
            end
        end


        return a, b
    end


    for i = 1, amount do -- normal method for non-stackable items
        local item = Game.createItem(itemId, subType)
        if player:addItemEx(item, ignoreCap) ~= RETURNVALUE_NOERROR then
            break
        end
        a = i
    end
    return a, 0
end
function doNpcSellItem(cid, itemId, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 0
    local item = 0
    local player = Player(cid)
    if ItemType(itemId):isStackable() then
        local stuff
        if inBackpacks then
            stuff = Game.createItem(backpack, 1)
            item = stuff:addItem(itemId, math.min(100, amount))
        else
            stuff = Game.createItem(itemId, math.min(100, amount))
        end


        return player:addItemEx(stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
    end


    local a = 0
    if inBackpacks then
        local container, itemType, b = Game.createItem(backpack, 1), ItemType(backpack), 1
        for i = 1, amount do
            local item = container:addItem(itemId, subType)
            if isInArray({(itemType:getCapacity() * b), amount}, i) then
                if player:addItemEx(container, ignoreCap) ~= RETURNVALUE_NOERROR then
                    b = b - 1
                    break
                end


                a = i
                if amount > i then
                    container = Game.createItem(backpack, 1)
                    b = b + 1
                end
            end
        end


        return a, b
    end


    for i = 1, amount do -- normal method for non-stackable items
        local item = Game.createItem(itemId, subType)
        if player:addItemEx(item, ignoreCap) ~= RETURNVALUE_NOERROR then
            break
        end
        a = i
    end
    return a, 0
end
 
Back
Top