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

Npc selling items/runes in backpack doesn't work

dami1310

◄ Unidentified ►
Joined
Jan 27, 2013
Messages
732
Solutions
12
Reaction score
664
Location
Poland
As in the title. I want to make npc sell potions and runes in backpacks possible.
Im using tfs 0.4, to be specific:
this one.
Here is my npc.lua:
Npc:
Npc script:

I tried different kind of solutions and files, but couldnt find the right one.

I somehow managed to get the right amounts of stackable and nonstackable items, but it's "fake" and for stackable items the price for bp is the same as for 100 :v
PHP:
function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 1
    local ignoreCap = ignoreCap and true or false
 
    local a = 0
    if(inBackpacks) then
        if(isItemStackable(itemid)) then
            amount = amount * 20
        end
        local container = doCreateItemEx(backpack, 1)
        local b = 1
        for i = 1, amount do
            item = doAddContainerItem(container, itemid, subType)
            if(itemid == ITEM_PARCEL) then
                doAddContainerItem(item, ITEM_LABEL)
            end
 
            if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
                if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
                    b = b - 1
                    break
                end
 
                if(isItemStackable(itemid)) then
                    i = i * 100
                end
                a = i
                if(amount > i) then
                    container = doCreateItemEx(backpack, 1)
                    b = b + 1
                end
            end
        end
 
        return a, b
    end
 
    for i = 1, amount do
        item = doCreateItemEx(itemid, subType)
        if(itemid == ITEM_PARCEL) then
            doAddContainerItem(item, ITEM_LABEL)
        end
 
        if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
            break
        end
 
        a = i
    end
 
    return a, 0
end
 
Last edited:
Back
Top