Boa noite pessoal,
estou com um problema meu npc vende runas com a opção buy with backpack do próprio tibia
mas ao comprar era pra vir a bp cheia né?
só que vem apenas 20 runas, sendo que coloquei para vender 100 por vez...
TFS 0.3.7 [8.60]
aqui o codigo do npc
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'blank rune'}, 2260, 5, 1,'blank rune')
shopModule:addBuyableItem({'heavy magic missile rune'}, 2311, 1000, 100, 'heavy magic missile rune')
shopModule:addBuyableItem({'ultimate healing rune'}, 2273, 3000, 100, 'ultimate healing rune')
shopModule:addBuyableItem({'great fireball rune'}, 2304, 2000, 100, 'great fireball rune')
shopModule:addBuyableItem({'explosion rune'}, 2313, 3000, 100, 'explosion rune')
shopModule:addBuyableItem({'sudden death rune'}, 2268, 4000, 100, 'sudden death rune')
shopModule:addBuyableItem({'mana rune'}, 2296, 10000, 100, 'mana rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 1000, 100, 'antidote rune')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
codigo da lib do npc
function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
local amount, subType, ignoreCap, inBackpacks, backpack = amount or 1, subType or 0, ignoreCap or false, inBackpacks or false, backpack or 1988
local exhaustionInSeconds = 1
local storage = 45814
if(exhaustion.check(cid, storage) == true) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cant buy it so fast.")
return 0
end
exhaustion.set(cid, storage, exhaustionInSeconds)
local ignoreCap = false
local item, a = nil, 0
if(inBackpacks) then
local custom, stackable = 1, isItemStackable(itemid)
if(stackable) then
custom = math.max(1, subType)
subType = amount
amount = math.max(1, math.floor(amount / 100))
end
local container, b = doCreateItemEx(backpack, 1), 1
for i = 1, amount * custom 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
a = i
if(amount > i) then
container = doCreateItemEx(backpack, 1)
b = b + 1
end
end
end
if(not stackable) then
return a, b
end
return (a * subType / custom), b
end
if(isItemStackable(itemid)) then
a = amount * math.max(1, subType)
repeat
local tmp = math.min(100, a)
item = doCreateItemEx(itemid, tmp)
if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
return 0, 0
end
a = a - tmp
until a == 0
return amount, 0
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