Ir para conteúdo

Featured Replies

Postado
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)

  • Respostas 5
  • Visualizações 767
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tenta assim

  • 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

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo