Postado Dezembro 28, 2018 6 anos 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 Editado Dezembro 28, 2018 6 anos por kTz (veja o histórico de edições)
Postado Dezembro 30, 2018 6 anos Spoiler if msgcontains(msg, 'bag de uh') then npcHandler:say("Aceita trocar {5 Crystal\'s Coin\'s} por uma bag com 400 {UH Runes}?", cid) talk_state = 1 elseif talk_state == 1 and msgcontains(msg, 'yes') then if getPlayerItemCount(cid,2160) >= 5 then doPlayerTakeItem(cid,2160,5) npcHandler:say("Aqui esta! Obrigado e volte sempre.", cid) doPlayerSendTextMessage(cid,22,"Voce recebeu uma bag de Runes.") container = doPlayerAddItem(cid, 1995, 1) doAddContainerItem(container, 2273, 100) doAddContainerItem(container, 2273, 100) doAddContainerItem(container, 2273, 100) doAddContainerItem(container, 2273, 100) talk_state = 0 else npcHandler:say("Desculpe, mas voce não tem Gold suficiente.", cid) end end Editado Dezembro 30, 2018 6 anos por Roy (veja o histórico de edições)
Postado Dezembro 31, 2018 6 anos Autor O problema que esse erro acontece quando o player usa o cliente do tibia para comprar no npc é possivel clicar com botão direito sobre a runa e escolher comprar com bp...
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.