Postado Novembro 10, 2015 9 anos Aqui está: Npc.lua local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local itemsp = {2666, 2671, 2681, 2695, 2667, 2676, 2675} -- os 7 items que precisam. s = "" for k, v in pairs(itemsp) do s = s.."{".. getItemNameById(v) .."}".. (#itemsp ~= k and ", " or "") end function pegaritems() for k, v in pairs(itemsp) do doPlayerRemoveItem(cid, v, 1) end end function temitem() for k, v in pairs(itemsp) do if not (getPlayerItemCount(cid, v) >= 1) then return false end end return true end local tab = { [2] = 7454, -- axe [3] = 2376, -- sword [4] = 2389, -- spear } if (msgcontains(msg, "troca") or msgcontains(msg, "trocar") or msgcontains(msg, "yes")) and talkState[talkUser] == nil then npcHandler:say("Ok, preciso de {7 items} em troca de: ("..getItemArticleById(tab[2]).." {"..getItemNameById(tab[2]).."} - ID: "..tab[2].."), ("..getItemArticleById(tab[3]).." {"..getItemNameById(tab[3]).."} - ID: "..tab[3]..") ou ("..getItemArticleById(tab[4]).." {"..getItemNameById(tab[4]).."} - ID: "..tab[4]..")", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, "axe")) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por um {axe}?", cid) talkState[talkUser] = 2 elseif (msgcontains(msg, "sword")) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por uma {sword}?", cid) talkState[talkUser] = 3 elseif (msgcontains(msg, "spear")) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por uma {spear}?", cid) talkState[talkUser] = 4 elseif (msgcontains(msg, "yes")) and tab[talkState[talkUser]] then for k, v in pairs(itemsp) do if not temitem() then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) npcHandler:say("Voce nao tem todos os items, desculpe, nada feito.", cid) npcHandler:onCreatureDisappear(cid) talkState[talkUser] = nil return true elseif temitem() then pegaritems() doPlayerAddItem(cid, tab[talkState[talkUser]]) npcHandler:say("Uhuul, troca feita, obrigado.", cid) npcHandler:onCreatureDisappear(cid) talkState[talkUser] = nil return true end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Npc.Xml <?xml version="1.0"?> <npc name="Troque aqui" script="trocador de item.lua" walkinterval="2000"> <mana now="800" max="800" /> <health now="200" max="200" /> <look type="132" head="0" body="0" legs="0" feet="0" addons="3" /> <parameters> <parameter key="message_greet" value="Ola, |PLAYERNAME|, gostaria de fazer uma {troca}?" /> <parameter key="message_farewell" value="Ate mais, |PLAYERNAME|!" /> <parameter key="message_walkaway" value="Valeu!" /> </parameters> Editado Novembro 10, 2015 9 anos por Caronte (veja o histórico de edições) Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado). Tópicos: [FAQ] BBCODE [LIB] Constant [RME] Administrando bordas. [TALK] Broadcast Editável. [TALK] Sugest. [TALK] Checkpoint. [MOVE] Pântano pegajoso. [ACTION] Piggy Bank. (Cassino). [GLOBAL] Uptime Ad. [C0DE] Consertando 'Invalid Password' [PROGRAM] Quest Maker
Postado Novembro 11, 2015 9 anos Autor Rep + Muito obrigado !! Editado Novembro 11, 2015 9 anos por Gabrielk (veja o histórico de edições)
Postado Novembro 13, 2015 9 anos Autor Coloca os 7 items para ter quantidade por favor.... a quantidade eu boto... Por favor.
Postado Novembro 13, 2015 9 anos local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local itemsp = {2666, 2671, 2681, 2695, 2667, 2676, 2675} -- os 7 items que precisam. s = "" for k, v in pairs(itemsp) do s = s.."{".. getItemNameById(v) .."}".. (#itemsp ~= k and ", " or "") end function pegaritems() for k, v in pairs(itemsp) do doPlayerRemoveItem(cid, v, 1) end end function temitem() for k, v in pairs(itemsp) do if not (getPlayerItemCount(cid, v) >= 1) then return false end end return true end local tab = { [2] = {7454, 4}, -- axe [3] = {2376, 2}, -- sword [4] = {2389, 2}, -- spear } if (msgcontains(msg, "troca") or msgcontains(msg, "trocar") or msgcontains(msg, "yes")) and talkState[talkUser] == nil then npcHandler:say("Ok, preciso de {7 items} em troca de: ("..getItemArticleById(tab[2][1]).." {"..getItemNameById(tab[2][1]).."} - ID: "..tab[2][1].."), ("..getItemArticleById(tab[3][1]).." {"..getItemNameById(tab[3][1]).."} - ID: "..tab[3][1]..") ou ("..getItemArticleById(tab[4][1]).." {"..getItemNameById(tab[4][1]).."} - ID: "..tab[4][1]..")", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, tostring(getItemNameById(tab[2][1])))) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por um {"..getItemNameById(tab[2][1]).."}?", cid) talkState[talkUser] = 2 elseif (msgcontains(msg, tostring(getItemNameById(tab[3][1])))) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por uma {"..getItemNameById(tab[3][1]).."}?", cid) talkState[talkUser] = 3 elseif (msgcontains(msg, tostring(getItemNameById(tab[4][1])))) and talkState[talkUser] == 1 then npcHandler:say("Voce quer trocar: ".. s .." por uma {"..getItemNameById(tab[4][1]).."}?", cid) talkState[talkUser] = 4 elseif (msgcontains(msg, "yes")) and tab[talkState[talkUser]] then for k, v in pairs(itemsp) do if not temitem() then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) npcHandler:say("Voce nao tem todos os items, desculpe, nada feito.", cid) npcHandler:onCreatureDisappear(cid) talkState[talkUser] = nil return true elseif temitem() then pegaritems() for i = 1, tab[talkState[talkUser]][2] do doPlayerAddItem(cid, tab[talkState[talkUser]][1]) end npcHandler:say("Uhuul, troca feita, obrigado.", cid) npcHandler:onCreatureDisappear(cid) talkState[talkUser] = nil return true end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado). Tópicos: [FAQ] BBCODE [LIB] Constant [RME] Administrando bordas. [TALK] Broadcast Editável. [TALK] Sugest. [TALK] Checkpoint. [MOVE] Pântano pegajoso. [ACTION] Piggy Bank. (Cassino). [GLOBAL] Uptime Ad. [C0DE] Consertando 'Invalid Password' [PROGRAM] Quest Maker
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.