Postado Novembro 13, 2015 9 anos Autor local itemsp = {2666, 2671, 2681, 2695, 2667, 2676, 2675} -- os 7 items que precisam. esse daqui que eu queria... por favor
Postado Novembro 13, 2015 9 anos Solução Em 13/11/2015 em 14:53, Gabrielk disse: local itemsp = {2666, 2671, 2681, 2695, 2667, 2676, 2675} -- os 7 items que precisam. esse daqui que eu queria... por favor Opa, desculpa, burrice minha. Agora ambos estão configuráveis: 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 = { [1] = {2666, 2}, [2] = {2671, 2}, [3] = {2681, 2}, [4] = {2695, 2}, [5] = {2667, 2}, [6] = {2676, 2}, [7] = {2675, 2}, } -- os 7 items que precisam. s = "" for k, v in pairs(itemsp) do s = s.."{"..v[2].." ".. getItemNameById(v[1]) .."}".. (#itemsp ~= k and ", " or "") end function pegaritems() for k, v in pairs(itemsp) do doPlayerRemoveItem(cid, v[1], v[2]) end end function temitem() for k, v in pairs(itemsp) do if not (getPlayerItemCount(cid, v[1]) >= v[2]) then return false end end return true end local tab = { [2] = {7454, 1}, -- axe [3] = {2376, 1}, -- sword [4] = {2389, 1}, -- 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: Mostrar conteúdo oculto [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.