• 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 1.X+ NPC change gold to bank balance

Gicu

Well-Known Member
Joined
Feb 26, 2011
Messages
187
Reaction score
52
I need some change sell items in NPC dont give gold.
Add count to bank balance.

i try change that but nothing change in game :/

Code:
function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 0
    local item = 0
    if isItemStackable(itemid) then
        if inBackpacks then
            stuff = doCreateItemEx(backpack, 1)
            item = doAddContainerItem(stuff, itemid, math.min(100, amount))
        else
            stuff = doCreateItemEx(itemid, math.min(100, amount))
            --stuff = doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
        end
        --return doPlayerSetBalance(cid, getPlayerBalance(cid) + stuff) ~= RETURNVALUE_NOERROR and 0 or amount, 0
        return doPlayerAddItemEx(cid, stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
    end

    local a = 0
    if inBackpacks then
        local container, b = doCreateItemEx(backpack, 1), 1
        for i = 1, amount do
            local item = doAddContainerItem(container, itemid, subType)
            if table.contains({(getContainerCapById(backpack) * b), amount}, i) then
                if doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR then
                    b = b - 1
                    break
                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 -- normal method for non-stackable items
        local item = doCreateItemEx(itemid, subType)
        if doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR then
            break
        end
        a = i
    end
    return a, 0
end
 
Back
Top