espero que ajude
local exchanges = {
{takeId = 2487, takeCount = 1, giveId = 5887, giveCount = 1, keywords = {'crown armor','piece of royal steel'}},
{takeId = 2195, takeCount = 1, giveId = 5891, giveCount = 1, keywords = {'boh','enchanted chicken wings'}},
{takeId = 2498, takeCount = 2, giveId = 5884, giveCount = 1, keywords = {'fighting spirit','royal helmet'}},
{takeId = 2475, takeCount = 4, giveId = 5885, giveCount = 1, keywords = {'warriors sweat','warrior helmet'}},
{takeId = 5879, takeCount = 10, giveId = 5886, giveCount = 1, keywords = {'spool of yarn','giant spider silk'}},
{takeId = 2393, takeCount = 1, giveId = 5892, giveCount = 1, keywords = {'crude iron','giant sword'}},
{takeId = 2462, takeCount = 1, giveId = 5888, giveCount = 1, keywords = {'devil helmet','piece of hell steel'}},
{takeId = 2516, takeCount = 1, giveId = 5889, giveCount = 1, keywords = {'dragon shield','piece of draconian steel'}},
}
local phrases = {
"Hello, |PLAYERNAME|! I'm a blacksmith. Did you bring something to me?",
"How rude!",
"Wait! I'm talking.",
"You don't have required items",
"Thank you so much.",
"Farewell, |PLAYERNAME|",
"Ohh, this is bad",
trade1="Do you want to trade your",
trade2="by"
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
npcHandler:setMessage(MESSAGE_GREET, phrases[1])
npcHandler:setMessage(MESSAGE_WALKAWAY, phrases[2])
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE, phrases[3])
npcHandler:setMessage(MESSAGE_FAREWELL, phrases[6])
local function cyclopsExchange(cid, message, keywords, parameters, node)
local exchange = exchanges[parameters.id]
if (not npcHandler:isFocused(cid)) then return false end
if doPlayerTakeItem(cid, exchange.takeId, exchange.takeCount) > 0 then
doPlayerAddItem(cid, exchange.giveId, exchange.giveCount)
npcHandler:say(phrases[5], cid)
else npcHandler:say(phrases[4], cid) end
keywordHandler:moveUp(1)
return TRUE
end
for i = 1, #exchanges do
local exchange = exchanges[i]
for a = 1, #exchange.keywords do
local node = keywordHandler:addKeyword({exchange.keywords[a]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text =phrases.trade1..' '..getItemName(exchange.takeId)..' '..phrases.trade2..' '..getItemName(exchange.giveId)..'?'})
node:addChildKeyword({'yes'}, cyclopsExchange, {id = i})
node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = phrases[7]})
end
end
npcHandler:addModule(FocusModule:new())
está testado e 90% funcional.. meu GM não cria items começados em 2 =/ então só pude testar a giant spider silk
faça o teste com o resto
se quiser adicionar mais alguma troca, basta adicionar dentro de exchanges seguindo o padrão:
{takeId = x, takeCount = y, giveId = a, giveCount = b, keywords{'key1','key2','key3'...}}
takeId = item a ser retirado do player
takeCount = quantidade de itens necessária
giveId = item a ser entregue ao player
giveCount = número de items que serão entregues OU em caso de items especiais... como runas ou fluids, aqui vem a propriedade do item ex:
giveId = 2268, giveCount = 50
entrega UMA sd, com 50 cargas
giveId = 2006, giveCount = 2
entrega UMA flask contendo blood
e por fim, para traduzir as falas do NPC, basta alterar as phrases, os valores dentro das aspas
se quiser npc channel, dê uma olhada neste link
http://www.xtibia.com/forum/84x-Npc-Channe...nn-t103175.html




info
Grupo: Campones
Registrado: 26/10/08
Posts: 35
Reputação: 0
Char no Tibia: Gnomow
é galera, vcs ja devem ta cansados de me ver aqui, mas sou bem noob msm
dessa vez é assim
PRECISO MUITOOO³ do npc A Sweaty Cyclops...
Entaum eu peguei um ae mas deve ser versao velha.. 8.20 sei la
E o problema é que ele ta sempre ocupado, soh da pra falar uma vez com ele, depois ele nao fala mais, diz que ta ocupado e tals...
e tb ele nao fala pelo chat NPCs por ser de uma versão mais velha, alguêm me ajuda ? xS
Script:
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('Olá ' .. creatureGetName(cid) .. '! Eu sou um ferreiro .. Tem algo para mim??') 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, 'crown armor') or msgcontains(msg,'piece of royal steel') then selfSay('Você quer trocar a Crown Armor pela Piece of royal steel ?') talk_state = 1 elseif msgcontains(msg, 'boh') or msgcontains(msg,'enchanted chicken wings') then selfSay('Você quer trocar a Boh pela Enchanted chicken wings ??') talk_state = 2 elseif msgcontains(msg, 'fighting spirit') or msgcontains(msg, 'royal helmet') then selfSay('Você quer trocar 2 Royal Helmet por Fighting spirit ??') talk_state = 3 elseif msgcontains(msg, 'warriors sweat') or msgcontains(msg,'warrior helmet') then selfSay('Você quer trocar 4 warrior helmet por warriors sweat ??') talk_state = 4 elseif msgcontains(msg, 'spool of yarn') or msgcontains(msg,'giant spider silk') then selfSay('Você quer trocar 10 giant spider silk por Spool of yarn ??') talk_state = 5 elseif msgcontains(msg, 'crude iron') or msgcontains(msg,'giant sword') then selfSay('Você quer trocar uma giant sword por um crude iron ??') talk_state = 6 elseif msgcontains(msg, 'devil helmet') or msgcontains(msg,'piece of hell steel') then selfSay('Você quer trocar um devil helmet por um piece of hell steel ??') talk_state = 7 elseif msgcontains(msg, 'dragon shield') or msgcontains(msg,'piece of draconian steel') then selfSay('Você quer trocar um dragon shield por um piece of draconian steel ??') talk_state = 8 elseif talk_state == 1 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2487,1) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5887,1) selfSay('Obrigado !!') end end talk_state = 0 elseif talk_state == 2 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2195,1) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5891,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 3 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2498,2) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5884,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 4 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2475,4) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5885,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 5 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,5879,10) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5886,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 6 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2393,1) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5892,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 7 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2462,1) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5888,1) selfSay('Thanks for items.') end end talk_state = 0 elseif talk_state == 8 then if msgcontains(msg, 'yes') then itemstatus = doPlayerRemoveItem(cid,2516,1) if itemstatus == 0 then selfSay('Sorry, you not have items.') else doPlayerAddItem(cid,5889,1) selfSay('Thanks for items.') end end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 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 end end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end endNpc:
Ficarei Grato se conseguirem arumar pra ele falar pelo NPCs Channel, mas o principal é ele falar com o próximo
Editado Fevereiro 1 por gnomow157