Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Olá pessoal eu andei tentando criar um npc que troca dois itens por 1.

Exemplo: Uma CHAIN ARMOR + GOLDEN ARMOR + 10k por um outro item... só que quando vou falar com ele , basta ter só uma chain armor ou só uma golden armor, ou só 10k que ele ja troca..nao precisa ter os 3, e eu gostaria que ele trocasse os 3 itens por 1. Vou postar foto do meu script.

É um OTSERVER 7.6 ..OTyourotz, bem antigo.

Se alguem souber me ajudar, por favor, ficarei muito grato!

Abraço!

 

Script

focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
      msg = string.lower(msg)

      if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
          selfSay('Hi ' .. creatureGetName(cid) .. '... I can forge A Forge Armor for you to bring me a Chain Armor and a Golden Armor , will charge a fee of 10000GPS...')
          focus = cid
          talk_start = os.clock()

      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

    elseif focus == cid then
        talk_start = os.clock()

if msgcontains(msg, 'forge armor') then    
    itemstatus = doPlayerRemoveItem(cid,2464) -- 2464 golden armor    
    itemstatus = doPlayerRemoveItem(cid,2466) -- 2466 chain armor
    itemstatus = doPlayerRemoveItem(cid,2160) -- 2160 crystal coin
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatus == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Forge Armor!')        
        buy(cid,2508,1,0) -- 2472 é o item que ele irá ganhar 
                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    
    else        
        selfSay('you do not have the necessary items...')    
end

if msgcontains(msg, 'helmet of the ancients') then    
    itemstatus = doPlayerRemoveItem(cid,2147) -- 2147 é o item que o player vai ter que dar pro npc    
    itemstatus = doPlayerRemoveItem(cid,2342) -- 2342 é o item que o player vai ter que dar pro npc
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatus == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Full Helmet of the Ancients!')        
        buy(cid,2343,1,0) -- 2343 é o item que ele irá ganhar 
                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    
    else        
        selfSay('It is missing something...')    
    end
end
        elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
            selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
            focus = 0
            talk_start = 0
        end
    end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
      if (os.clock() - talk_start) > 30 then
          if focus > 0 then
              selfSay('Next Please...')
          end
              focus = 0
      end
     if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
         end
     end
end
 

 

Link para o post
Compartilhar em outros sites
Spoiler

 

focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
      msg = string.lower(msg)

      if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
          selfSay('Hi ' .. creatureGetName(cid) .. '... I can forge A Forge Armor for you to bring me a Chain Armor and a Golden Armor , will charge a fee of 10000GPS...')
          focus = cid
          talk_start = os.clock()

      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

    elseif focus == cid then
        talk_start = os.clock()

if msgcontains(msg, 'forge armor') then    
    itemstatusum = doPlayerRemoveItem(cid,2464) -- 2464 golden armor    
    itemstatusdois = doPlayerRemoveItem(cid,2466) -- 2466 chain armor
    itemstatustres = doPlayerRemoveItem(cid,2160) -- 2160 crystal coin
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatusum == 0 and itemstatusdois == 0 and itemstatustres == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Forge Armor!')        
        buy(cid,2508,1,0) -- 2472 é o item que ele irá ganhar 
                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    
    else        
        selfSay('you do not have the necessary items...')    
end

if msgcontains(msg, 'helmet of the ancients') then    
    itemstatusum = doPlayerRemoveItem(cid,2147) -- 2147 é o item que o player vai ter que dar pro npc    
    itemstatusdois = doPlayerRemoveItem(cid,2342) -- 2342 é o item que o player vai ter que dar pro npc
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatusum == 0 and itemstatusdois == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Full Helmet of the Ancients!')        
        buy(cid,2343,1,0) -- 2343 é o item que ele irá ganhar 
                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    
    else        
        selfSay('It is missing something...')    
    end
end
        elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
            selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
            focus = 0
            talk_start = 0
        end
    end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
      if (os.clock() - talk_start) > 30 then
          if focus > 0 then
              selfSay('Next Please...')
          end
              focus = 0
      end
     if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
         end
     end
end

 

Tenta assim

Link para o post
Compartilhar em outros sites

ai irmao, tentei, mas o que acontece , se eu tenho por exemplo UM item dos que precisa pra ''fazer'' a armadura, ele simplismente some, mas se eu tenho todos os itens ele faz a armadura.

 

Link para o post
Compartilhar em outros sites
3 horas atrás, fedegrodas21 disse:

ai irmao, tentei, mas o que acontece , se eu tenho por exemplo UM item dos que precisa pra ''fazer'' a armadura, ele simplismente some, mas se eu tenho todos os itens ele faz a armadura.

 

 

Esquece esse script, tenta esse:

 

data/npc/scripts/blacksmith.lua

local tab = {
	item = {2349, 1}, -- {ID do item, Quantidade} mude para os itens que voce quer, pois esses sao itens de teste que usei
	item2 = {2346, 1},
	item3 = {2156, 1},
	recompensa = {5791, 1}, -- Armadura que vai ganhar se tiver todos os itens
	price = 10 -- quantidade em crystal coins
	
}

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 creatureSayCallback(cid, type, msg)
	if (not npcHandler:isFocused(cid)) then
		return false
	end
	
	local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
	if (msgcontains(msg, 'forge armor')) then
		talkState[talkUser] = 1
		selfSay('Lembre-se.. Voce precisa de '..tab.item[2]..' '..getItemNameById(tab.item[1])..', '..tab.item2[2]..' '..getItemNameById(tab.item2[1])..', '..tab.item3[2]..' '..getItemNameById(tab.item3[1])..' e 10k. Ja possui todos?', cid)
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and
			getPlayerItemCount(cid, tab.item2[1]) >= tab.item2[2] and 
			getPlayerItemCount(cid, tab.item3[1]) >= tab.item3[2] and
			doPlayerRemoveMoney(cid, tab.price * 1000)) then
			doPlayerRemoveItem(cid, tab.item[1], tab.item[2])
			doPlayerRemoveItem(cid, tab.item2[1], tab.item2[2])
			doPlayerRemoveItem(cid, tab.item3[1], tab.item3[2])
			doPlayerAddItem(cid,tab.recompensa[1],tab.recompensa[2])
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			selfSay('Veja so, voce tem todos os itens, parabens, aproveite sua nova armadura!.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Perdao, mas voce nao tem os itens necessarios ainda, volte quando estiver com todos.', cid)
		end
	elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then
		talkState[talkUser] = 0
		selfSay('Pois bem, pegue os itens e retorne.', cid)
	end
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

data/npc/blacksmith.xml

<npc name="Blacksmith" script="data/npc/scripts/blacksmith.lua" access="5" lookdir="1">
<health now="1000" max="1000"/>
<look type="54" head="45" body="67" legs="79" feet="10" addons="1"/>
	<parameters>
		<parameter key="message_greet" value="Ola, |PLAYERNAME|. Se voce tiver os itens certos diga {forge armor} e ganhe uma armadura nova." />
	</parameters>
</npc>

 

Script de @Wise , adaptei para sua necessidade.

Link para o post
Compartilhar em outros sites
Spoiler

focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
      msg = string.lower(msg)

      if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
          selfSay('Hi ' .. creatureGetName(cid) .. '... I can forge A Forge Armor for you to bring me a Chain Armor and a Golden Armor , will charge a fee of 10000GPS...')
          focus = cid
          talk_start = os.clock()

      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

    elseif focus == cid then
        talk_start = os.clock()

if msgcontains(msg, 'forge armor') then    
    itemstatusum = doPlayerRemoveItem(cid,2464) -- 2464 golden armor    
    itemstatusdois = doPlayerRemoveItem(cid,2466) -- 2466 chain armor
    itemstatustres = doPlayerRemoveItem(cid,2160) -- 2160 crystal coin
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatusum == 0 and itemstatusdois == 0 and itemstatustres == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Forge Armor!')        
        buy(cid,2508,1,0) -- 2472 é o item que ele irá ganhar 
        return true        

                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    
    else        
        selfSay('you do not have the necessary items...')

        return false    
end

if msgcontains(msg, 'helmet of the ancients') then    
    itemstatusum = doPlayerRemoveItem(cid,2147) -- 2147 é o item que o player vai ter que dar pro npc    
    itemstatusdois = doPlayerRemoveItem(cid,2342) -- 2342 é o item que o player vai ter que dar pro npc
    needmoney = 0 -- qntidade que o player precisa pagar (em GPs)    
    money = pay(cid,needmoney)    
    if itemstatusum == 0 and itemstatusdois == 0 and money == true then        
        selfSay('Hmm, this is incredible! Take this Full Helmet of the Ancients!')        
        buy(cid,2343,1,0) -- 2343 é o item que ele irá ganhar 
        return true        

                -- note que o preço do item é 0, ou seja,                
                -- o player irá pagar 0 GPs pelo item;    

     else        
        selfSay('It is missing something...')  

        return false 
    end
end
        elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
            selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
            focus = 0
            talk_start = 0
        end
    end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
      if (os.clock() - talk_start) > 30 then
          if focus > 0 then
              selfSay('Next Please...')
          end
              focus = 0
      end
     if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
         end
     end
end

Ai mano esse deve dar.

Editado por Crlixto (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo