Olá nobres amigos, eu novamente.
Servidor: TFS 0.3.6
Cliente: 8.60
Durante o desenvolvimento de meu servidor notei que os itens que possui cargas/charges, exemplo: amuletos, estavam todos sendo vendidos/comprados apenas com uma carga pelo NPC, mesmo que no itens.xml estivesse declarado a tag com o numero de cargas/charges desejado, através das minhas efetuei a seguinte correção:
Em npc/lib/npcsystem/modules.lua localize a seguinte função addBuyableItem e substitua por:
function ShopModule:addBuyableItem(names, itemid, cost, subType, realName)
if (type(subType) == 'string' and realName == nil) then
realName = subType
subType = nil
end
local v = getItemInfo(itemid)
if (SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
if (self.npcHandler.shopItems[itemid] == nil) then
self.npcHandler.shopItems[itemid] = {
buyPrice = -1,
sellPrice = -1,
subType = tonumber(subType) or (v.charges > 0 and v.charges or 0),
realName = ""
}
end
self.npcHandler.shopItems[itemid].buyPrice = cost
self.npcHandler.shopItems[itemid].realName = realName or getItemNameById(itemid)
self.npcHandler.shopItems[itemid].subType = tonumber(subType) or (v.charges > 0 and v.charges or 1)
end
if (names ~= nil and SHOPMODULE_MODE ~= SHOPMODULE_MODE_TRADE) then
local parameters = {
itemid = itemid,
cost = cost,
eventType = SHOPMODULE_BUY_ITEM,
module = self,
realName = realName or v.name,
subType = tonumber(subType) or (v.charges > 0 and v.charges or 1)
}
for i, name in pairs(names) do
local keywords = {}
table.insert(keywords, 'buy')
table.insert(keywords, name)
local node = self.npcHandler.keywordHandler:addKeyword(keywords, ShopModule.tradeItem, parameters)
node:addChildKeywordNode(self.yesNode)
node:addChildKeywordNode(self.noNode)
end
end
end
No mesmo arquivo altere também a função addSellableItem:
function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = getItemInfo(itemid)
if (SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
if (self.npcHandler.shopItems[itemid] == nil) then
self.npcHandler.shopItems[itemid] = {
buyPrice = -1,
sellPrice = -1,
subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
realName = ""
}
end
self.npcHandler.shopItems[itemid].sellPrice = cost
self.npcHandler.shopItems[itemid].realName = realName or v.name
end
if (names ~= nil and SHOPMODULE_MODE ~= SHOPMODULE_MODE_TRADE) then
local parameters = {
itemid = itemid,
cost = cost,
eventType = SHOPMODULE_SELL_ITEM,
module = self,
realName = realName or v.name
}
for i, name in pairs(names) do
local keywords = {}
table.insert(keywords, 'sell')
table.insert(keywords, name)
local node = self.npcHandler.keywordHandler:addKeyword(keywords, ShopModule.tradeItem, parameters)
node:addChildKeywordNode(self.yesNode)
node:addChildKeywordNode(self.noNode)
end
end
end
Aqui funcionou perfeitamente, venda dos agrupáveis e compra de itens com charges.
Vida de desenvolvedor é resolver um bug e criar outro
Espero ter ajudado 😄