Ir para conteúdo
  • 0

[Resolvido] NPCS compram itens equipados


Pedrosass

Pergunta

OT 8.6(TFS 0.4.0 rev 3777). 

Boa dia/tarde/noite galera do Xtibia, estou com um problema não muito critico, mas que atrapalha muito qualquer jogador. 

Como o titulo ja diz, quando vc vai vender seu loot (da backpack) e o item que vc for vender for o mesmo ID do que tiver equipado em um dos slots de equips, o NPC acaba levando o que ta equipado. Eu mesmo fiz uma gabiarra para evitar esse tipo de transtorno porém não é de fato a solução. Se alguém que manje um pouco mais puder ajudar eu agradeço. Segue UMA PARTE do script de sistema do NPC :

-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
	function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
		local shopItem = nil
		for _, item in ipairs(self.npcHandler.shopItems) do
			if(item.id == itemid and item.subType == subType) then
				shopItem = item
				break
			end
		end

		if(shopItem == nil) then
			print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'ShopModule.onSell - Item not found on shopItems list')
			return false
		end

		if(shopItem.sell == -1) then
			print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'ShopModule.onSell - Attempt to sell an item which is only buyable')
			return false
		end

		local parseInfo = {
			[TAG_PLAYERNAME] = getPlayerName(cid),
			[TAG_ITEMCOUNT] = amount,
			[TAG_TOTALCOST] = amount * shopItem.sell,
			[TAG_ITEMNAME] = shopItem.name
		}

		function GetEquippedItems(cid,itemid)
			items = {}

			for i = CONST_SLOT_FIRST, CONST_SLOT_LAST do
			item = getPlayerSlotItem(cid, i).itemid
			table.insert(items, item)        
			end
			return items
		end
		
		--   GAMBIARRA --
		if isInArray(GetEquippedItems(cid,itemid), itemid) then
			 doPlayerSendTextMessage(cid, 22, "Guarde seus equips no depot antes de realizar a venda do loot.") 
			 return true
		 end
					
		if(doPlayerRemoveItem(cid, itemid, amount, subType)) then
			local msg = self.npcHandler:getMessage(MESSAGE_SOLD)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, self.npcHandler:parseMessage(msg, parseInfo))
			doPlayerAddMoney(cid, amount * shopItem.sell)
	
			if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
				self.npcHandler.talkStart[cid] = os.time()
			else
				self.npcHandler.talkStart = os.time()
			end

			return true
		end

		local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM)
		doPlayerSendCancel(cid, self.npcHandler:parseMessage(msg, parseInfo))
		if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
			self.npcHandler.talkStart[cid] = os.time()
		else
			self.npcHandler.talkStart = os.time()
		end

		return false
	end

 

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Não sou scripter então não posso ajudar muito
é só nesse npc que ocorre este erro?
já tentou adicionar os itens de venda e compra direto na xml do npc assim?

<!--SHOP-->
		<parameter key="module_shop" value="1"/>
		<parameter key="shop_buyable" value="blankpoetryparchment,7528,1"/>
		<parameter key="shop_sellable" value="badger fur,11216,1;destroy field rune,2261,1"/>

e você usa client old ou OT client? o OT client tem uma opção no npc parar ignorar item equipado

928984137_itemequip.thumb.png.86cc6121c13d503c4608d9e6b95f4108.png

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...