Ir para conteúdo

Real Addons Trader 8.1


speedyks

Posts Recomendados

Olá, venho postar um NPC feito por Evil Hero, e modificado por mim...

 

Vá em data/npc/ crie um novo arquivo xml com o nome que desejar exemplo: AddonTrader.xml

Abra-o e coloque isso:

 

<?xml version="1.0"?>

<npc name="[color="#FF0000"]Nomedonpc[/color]" script="data/npc/scripts/exchange.lua" access="3" lookdir="2" autowalk="0">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="251" head="114" body="119" legs="132" feet="114" addons="3"/>
</npc>

 

Caso queira seguir o nome do NPC de AddonTrader mude onde está escrito "Nomedonpc" para "AddonTrader"

Após renomear o NPC poderá salvar o arquivo e feichar.

___________________________________________________

 

Em data/npc/scripts crie um novo arquivo LUA com o nome de Exchange.lua

E cole isso:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
   -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
   if(npcHandler.focus ~= cid) then
       return false
   end

       if msgcontains(msg, 'offer') then
           selfSay('I can Trade Fighting Spirit, Warriors Sweat, Spool of Yarn, Enchanted Chicken Wings and a Blessed Wooden Stake for some special Items')
       elseif msgcontains(msg, 'fighting spirit') then
           selfSay('Do you like to trade 2 Royal Helmet for a Fighting Spirit?')
           talk_state = 1


       elseif msgcontains(msg, 'yes') and talk_state == 1 then
           if getPlayerItemCount(cid,2498) >= 2 then
               if doPlayerTakeItem(cid,2498,2) == 0 then
               selfSay('Here you are.')
                   doPlayerAddItem(cid,5884,1)
               end
           else
               selfSay('Sorry, you don\'t have the item.')
           end


       elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
           selfSay('Ok thanks.')
           talk_state = 0
       end

       if msgcontains(msg, 'warriors sweat') then
           selfSay('Do you like to trade 4 Warrior Helmet Helmet for a Warriors Sweat?')
           talk_state = 2


       elseif msgcontains(msg, 'yes') and talk_state == 2 then
           if getPlayerItemCount(cid,2475) >= 4 then
               if doPlayerTakeItem(cid,2475,4) == 0 then
               selfSay('Here you are.')
                   doPlayerAddItem(cid,5885,1)
               end
           else
               selfSay('Sorry, you don\'t have the item.')
           end


       elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
           selfSay('Ok thanks.')
           talk_state = 0
       end

       if msgcontains(msg, 'spool of yarn') then
           selfSay('Do you like to trade 10 Giant Spider Silk for a Spool of Yarn?')
           talk_state = 3


       elseif msgcontains(msg, 'yes') and talk_state == 3 then
           if getPlayerItemCount(cid,5879) >= 10 then
               if doPlayerTakeItem(cid,5879,10) == 0 then
               selfSay('Here you are.')
                   doPlayerAddItem(cid,5886,1)
               end
           else
               selfSay('Sorry, you don\'t have the item.')
           end


       elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
           selfSay('Ok thanks.')
           talk_state = 0
       end

       if msgcontains(msg, 'enchanted chicken wings') then
           selfSay('Do you like to trade Boots of Haste for some Enchanted Chicken Wings?')
           talk_state = 4


       elseif msgcontains(msg, 'yes') and talk_state == 4 then
           if getPlayerItemCount(cid,2195) >= 1 then
               if doPlayerTakeItem(cid,2195,1) == 0 then
               selfSay('Here you are.')
                   doPlayerAddItem(cid,5891,1)
               end
           else
               selfSay('Sorry, you don\'t have the item.')
           end


       elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
           selfSay('Ok thanks.')
           talk_state = 0
       end

       if msgcontains(msg, 'blessed wooden stake') then
           selfSay('Do you like to trade 100k for a Blessed Wooden Stake?')
           talk_state = 5


       elseif msgcontains(msg, 'yes') and talk_state == 5 then
           if getPlayerItemCount(cid,2160) >= 10 then
               if doPlayerTakeItem(cid,2160,10) == 0 then
               selfSay('Here you are.')
                   doPlayerAddItem(cid,5942,1)
               end
           else
               selfSay('Sorry, you don\'t have the item.')
           end


       elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then
           selfSay('Ok thanks.')
           talk_state = 0
       end
   -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
   return true
end

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

 

Salve o arquivo, e feiche-o.

Pronto seu NPC está configurado :)

Agora é so dizer HI o nome do addon e procurar o item que ele pedir :)

 

Atenção: Partes do texto em vermelho são coisas que você precisa fazer para que de certo :)

 

__________________________________________________________

 

Créditos totalmente a Evil Hero

Link para o comentário
Compartilhar em outros sites

  • 2 weeks later...

MrStyle

Mal ae perguntar, mas onde ele fica.. novato =/

 

Tpo c vc tiver o seu map editor eu nao sei c vai ter lah o npc q vc criou , mais para um test crie com o seu GOD /s (nomedonpc)

 

 

 

vlw aew pelo tuto ^^ :smile_positivo:

Editado por Raulzito
Link para o comentário
Compartilhar em outros sites

Desculpa mas esse NPC, n dah addon , mas sim troca itens por outros que podem ser usados em addon, é um npc trader

PS:Olhem sempre oque voce posta

&Tádzio&

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...