• 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+ [bug] buying items from eq

Svira

Active Member
Joined
Jan 27, 2008
Messages
268
Solutions
11
Reaction score
36
Hello gentlemen! I have a problem. I noticed that after adding the system slot, my NPCs dealing in item trading started buying items from EQ, where to look and how to fix this problem? I found some old solutions with old svn, I need a fix for tfs 1.2

npc/lib, I've probably searched everything!
 
Solution
In this solution I have to edit all npc.lua that deal with sales. Can it be converted to lib?

I have over 220 items purchasing and it will be very time-consuming ;/
You can try as follows:
open the following file npc/lib/npc.lua

search for:
Lua:
function doPlayerSellItem(cid, itemid, count, cost)
    local player = Player(cid)
    if player:removeItem(itemid, count) then
        if not player:addMoney(cost) then
            error('Could not add money to ' .. player:getName() .. '(' .. cost .. 'gp)')
        end
        return true
    end
    return false
end

change for:

Lua:
function doPlayerSellItem(cid, itemid, count, cost, itemSubType, ignoreEquipped)
    local player = Player(cid)
    if player:removeItem(itemid...
I created a custom script a long time ago for a guy where NPCs don't trade with slots; they only trade with the player's backpack. I added a function 'local slotItem = player:getSlotItem(SLOT_ARMOR),' and it worked just fine. Take a look at this post!
 
I created a custom script a long time ago for a guy where NPCs don't trade with slots; they only trade with the player's backpack. I added a function 'local slotItem = player:getSlotItem(SLOT_ARMOR),' and it worked just fine. Take a look at this post!
In this solution I have to edit all npc.lua that deal with sales. Can it be converted to lib?

I have over 220 items purchasing and it will be very time-consuming ;/
 
In this solution I have to edit all npc.lua that deal with sales. Can it be converted to lib?

I have over 220 items purchasing and it will be very time-consuming ;/
You can try as follows:
open the following file npc/lib/npc.lua

search for:
Lua:
function doPlayerSellItem(cid, itemid, count, cost)
    local player = Player(cid)
    if player:removeItem(itemid, count) then
        if not player:addMoney(cost) then
            error('Could not add money to ' .. player:getName() .. '(' .. cost .. 'gp)')
        end
        return true
    end
    return false
end

change for:

Lua:
function doPlayerSellItem(cid, itemid, count, cost, itemSubType, ignoreEquipped)
    local player = Player(cid)
    if player:removeItem(itemid, count, itemSubType, ignoreEquipped == nil and true or ignoreEquipped) then
        if not player:addMoney(cost) then
            error('Could not add money to ' .. player:getName() .. '(' .. cost .. 'gp)')
        end
        return true
    end
    return false
end

also, go to npc/lib/npcsystem/modules.lua
search for:
Lua:
local ret = doPlayerSellItem(cid, shop_itemid[cid], shop_amount[cid], shop_cost[cid] * shop_amount[cid])
change for:
Lua:
            local itemSubType = -1
            if ItemType(shop_itemid[cid]):isFluidContainer() then
                itemSubType = 0
            end
            local ret = doPlayerSellItem(cid, shop_itemid[cid], shop_amount[cid], shop_cost[cid] * shop_amount[cid], itemSubType, true)


then, search for:
Lua:
if player:removeItem(itemid, amount, subType, ignoreEquipped) then
change to:
Lua:
if player:removeItem(itemid, amount, subType, ignoreEquipped == nil and true or ignoreEquipped) then
 
Last edited:
Solution
Back
Top