Ir para conteúdo

Posts Recomendados

[Npc] Vendedor de Loot

 

  1. Abra a pasta: data/npc/scripts
  2. Copie qualquer arquivo e renomei por isso: Lootbuy.lua
  3. Acesse-o e cole isso:
     
    local focus = 0
    local talk_start = 0
    local target = 0
    local following = false
    local 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('Hello ' .. getCreatureName(cid) .. '! Eu vendo swords, clubs, axes,legs, shields e armors.')
    	  focus = cid
    	  talk_start = os.clock()
    
    elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
    	  selfSay('Sorry, ' .. getCreatureName(cid) .. '! Espere um minuto.')
    
      elseif focus == cid then
    	talk_start = os.clock()
    
    	  if msgcontains(msg, 'mystic turban') then
    		  sell(cid,2663,getCount(msg),500)
    			elseif msgcontains(msg, 'steel helmet') then
    		  buy(cid,2457,getCount(msg),1200)
    	  elseif msgcontains(msg, 'chain helmet') then
    		  buy(cid,2458,getCount(msg),150)
    			elseif msgcontains(msg, 'brass helmet') then
    		  buy(cid,2460,getCount(msg),90)
    			elseif msgcontains(msg, 'studded helmet') then
    		  buy(cid,2482,getCount(msg),40)
    	  elseif msgcontains(msg, 'helmets') then
    		  selfSay('Eu vendo chain helmet (150gp), steel helmet (1200gp),brass helmet (90gp) e studded helmet (40gp).')
    
    			elseif msgcontains(msg, 'mammoth fur cape') then
    		  buy(cid,7463,getCount(msg),6000)
    	elseif msgcontains(msg, 'plate armor') then
    		  buy(cid,2463,getCount(msg),800)
    	elseif msgcontains(msg, 'brass armor') then
    		  buy(cid,2465,getCount(msg),400)
    	elseif msgcontains(msg, 'chain armor') then
    		  buy(cid,2464,getCount(msg),150)
    	  elseif msgcontains(msg, 'armors')  then
    		  selfSay('Eu vendo plate (800gp), brass (400gp) and chain armors (150gp), tambem mammoth fur cape (6k).')
    
    	  elseif msgcontains(msg, 'brass legs') then
    		  buy(cid,2478,getCount(msg),200)
    		elseif msgcontains(msg, 'chain legs') then
    		  buy(cid,2478,getCount(msg),100)
    	  elseif msgcontains(msg, 'legs')  then
    		  selfSay('Eu vendo brass (200gp) and chain legs (100gp).')
    
    			elseif msgcontains(msg, 'steel shield') then
    		  buy(cid,2511,getCount(msg),180)
    			elseif msgcontains(msg, 'plate shield') then
    		  buy(cid,2510,getCount(msg),145)
    	elseif msgcontains(msg, 'dwarven shield') then
    		  buy(cid,2525,getCount(msg),300)
    	elseif msgcontains(msg, 'shields')  then
    		  selfSay('Eu vendo plate (145gp),steel (180gp) and dwarven shields (300gp).')
    
    	elseif msgcontains(msg, 'serpent sword')  then
    		  buy(cid,2409,getCount(msg),3500)
    	elseif msgcontains(msg, 'spike sword')  then
    		  buy(cid,2383,getCount(msg),2800)
    	  elseif msgcontains(msg, 'two handed sword')  then
    		  buy(cid,2377,getCount(msg),2400)
    	elseif msgcontains(msg, 'swords')  then
    		  selfSay('Eu vendo serpent (3.5k), spike (2.8k) and two handed swords (2.4k).')
    
    	elseif msgcontains(msg, 'double axe')  then
    		  buy(cid,2387,getCount(msg),2200)
    	elseif msgcontains(msg, 'halberd')  then
    		  buy(cid,2381,getCount(msg),2400)
    	elseif msgcontains(msg, 'battle axe')  then
    		  buy(cid,2378,getCount(msg),200)
    	  elseif msgcontains(msg, 'hatchet')  then
    		  buy(cid,2388,getCount(msg),60)
    			elseif msgcontains(msg, 'beastslayer axe') then
    		  buy(cid,3962,getCount(msg),7000)
    			elseif msgcontains(msg, 'barbarian axe') then
    		  buy(cid,2429,getCount(msg),1800)
    	elseif msgcontains(msg, 'axes')  then
    		  selfSay('Eu vendo double (2.2k), beastslayer axe (6k), barbarian (1.8k) halberds (2.4k) e hatchets (60gp).')
    
    	  elseif msgcontains(msg, 'clerical mace')  then
    		  buy(cid,2423,getCount(msg),1200)
    	  elseif msgcontains(msg, 'battle hammer')  then
    		  buy(cid,2417,getCount(msg),900)
    	  elseif msgcontains(msg, 'mace') then
    		  buy(cid,2398,getCount(msg),90)
    			elseif msgcontains(msg, 'dragonbone staff') then
    		  buy(cid,7430,getCount(msg),5800)
    	elseif msgcontains(msg, 'clubs')  then
    		  selfSay('Eu vendo battle hammers (900gp), dragonbone staff (5.8k) e clerical maces (1.2k).')
    
    	elseif msgcontains(msg, 'scarf') then
    		  buy(cid,2661,getCount(msg),1000)
    	elseif msgcontains(msg, 'amulets')  then
    		  selfSay('Eu vendo scarf (1k).')
    
    	  elseif string.find(msg, '(%a*)bye(%a*)')  and getDistanceToCreature(cid) < 4 then
    		  selfSay('Tchau, Tchau, ' .. getCreatureName(cid) .. '!')
    		  focus = 0
    		  talk_start = 0
    	  end
      end
    end
    
    
    function onCreatureChangeOutfit(creature)
    
    end
    
    function onThink()
    
    if (os.clock() - talk_start) > 20 then
    	  if focus > 0 then
    		  selfSay('...')
    	  end
    		  focus = 0
      end
    	if focus ~= 0 then
    		if getDistanceToCreature(focus) > 5 then
    			selfSay('...')
    			focus = 0
    		end
    	end
    end


     

  4. Vá em arquivo -> salvar.
  5. Acesse a pasta: data/npc
  6. Copie qualquer npc e renomeio para Vendedor de Loot.
  7. Abra o arquivo e cole isso:
     
    <?xml version="1.0"?>
    
    <npc name="Vendedor de Loot" script="data/npc/scripts/Lootbuy.lua" access="3" lookdir="2" autowalk="25">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
    <look type="251" head="0" body="114" legs="96" feet="76" addons="3"/>
    </npc>


     

  8. Pronto!, salve o arquivo.

 

Créditos: Thyrania pelo script e Northon pelo tutorial.

Editado por Northon
Link para o comentário
https://xtibia.com/forum/topic/89395-npc-vendedor-de-loot/
Compartilhar em outros sites

  • 2 weeks later...
×
×
  • Criar Novo...