Postado Dezembro 27, 2014 10 anos Olá, sou novo aqui no fórum e estou montando um servidor onde necessito de um NPC da seguinte maneira. O player vai falar com o NPC e o mesmo pede uma quantia X de items, por exemplo - 1 Demon Armor e 1 Demon Legs e após entregar os items ele é teletransportado para uma sala com uma Quest onde lá haverá o item "valioso". Obs: Ele não poderá fazer a quest novamente. Quem puder ajudar, vou ficar grato, vlw! Editado Dezembro 27, 2014 10 anos por luckzinsalles (veja o histórico de edições)
Postado Dezembro 27, 2014 10 anos Solução Va na pasta data/npc e crie um arquivo chamado Jamez.xml e coloque isso dentro: <?xml version="1.0" encoding="UTF-8"?> <npc name="Jamez" script="data/npc/scripts/jamez.lua" walkinterval="1500" speed="100" walkradius="2" floorchange="0"> <health max="100" now="100"/> <look type="129" head="115" body="88" legs="85" feet="114" addons="0" mount="0"/> <parameters> <!--MESSAGES--> <parameter key="message_greet" value="Hello, |PLAYERNAME|. Do you want to make a quest?"/> <parameter key="message_farewell" value="Good bye, |PLAYERNAME|."/> </parameters> </npc> Agora va na pasta data/npc/scripts e crie um arquivo chamado jamez.lua e coloque isso dentro: 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 local item1 = 2494 --Demon Armor local qntd1 = 1 --Quantidade do item 1 local item2 = 2495 --Demon Legs local qntd2 = 1 --Quantidade do item 2 local pos = {x=1, y=1, z=1} --Posicao pra onde o player vai ser teleportado local stor = 6967 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'yes') then selfSay('To do this quest you need to give me a Demon Armor and a Demon Legs. Do you have it?', cid) if msgcontains(msg, 'yes') then if getPlayerItemCount(cid, item1) >= qntd1 and getPlayerItemCount(cid, item2) >= qntd2 then if getPlayerStorageValue(cid, stor) ~= 1 then doPlayerRemoveItem(cid, item1, qntd1) doPlayerRemoveItem(cid, item2, qntd2) doTeleportThing(cid, pos) doSendMagicEffect(getThingPos(cid), 13) setPlayerStorageValue(cid, stor, 1) else selfSay('Voce ja fez esta quest.', cid) end else selfSay('Voce nao tem os itens necessarios pra fazer esta quest.', cid) end elseif msgcontains(msg, 'no') then selfSay('So go away! I have nothing to you.', cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Funciona assim, qnd o player falar hi, o npc pergunta se ele qr fazer uma quest. Ao responder yes o npc pergunta se o player tem os itens. Se disser sim e tiver os itens, o player é teleportado. Não esqueça de configurar isso no script .lua do npc: local item1 = 2494 --Demon Armor local qntd1 = 1 --Quantidade do item 1 local item2 = 2495 --Demon Legs local qntd2 = 1 --Quantidade do item 2 local pos = {x=1, y=1, z=1} --Posicao pra onde o player vai ser teleportado Editado Janeiro 25, 2015 10 anos por danihcv (veja o histórico de edições) Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Janeiro 25, 2015 10 anos Autor @EDIT ELE NÃO RECOLHE OS ITENS, APÓS SER TELEPORTADO ELE CONTINUA! Preciso que ele remova. Editado Janeiro 25, 2015 10 anos por luckzinsalles (veja o histórico de edições)
Postado Janeiro 25, 2015 10 anos Desculpe, foi falta de atenção. 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 local item1 = 2494 --Demon Armor local qntd1 = 1 --Quantidade do item 1 local item2 = 2495 --Demon Legs local qntd2 = 1 --Quantidade do item 2 local pos = {x=1, y=1, z=1} --Posicao pra onde o player vai ser teleportado local stor = 6967 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'yes') then selfSay('To do this quest you need to give me a Demon Armor and a Demon Legs. Do you have it?', cid) if msgcontains(msg, 'yes') then if getPlayerItemCount(cid, item1) >= qntd1 and getPlayerItemCount(cid, item2) >= qntd2 then if getPlayerStorageValue(cid, stor) ~= 1 then doPlayerRemoveItem(cid, item1, qntd1) doPlayerRemoveItem(cid, item2, qntd2) doTeleportThing(cid, pos) doSendMagicEffect(getThingPos(cid), 13) setPlayerStorageValue(cid, stor, 1) else selfSay('Voce ja fez esta quest.', cid) end else selfSay('Voce nao tem os itens necessarios pra fazer esta quest.', cid) end elseif msgcontains(msg, 'no') then selfSay('So go away! I have nothing to you.', cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
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.