Postado Julho 22, 2015 9 anos Olá pessoas do TK, preciso de um NPC que peça esses seguintes itens: 2318 ( Brooch ) 2174 ( Strange Symbol ) 2159 ( Scarab Coins ) 1 de cada e em compensação o prêmio será a chave: 2090 ( Crystal Key ) --------------------------------- Nome: Anciao Looktype: 309
Postado Julho 22, 2015 9 anos Solução Não está muito bom, mas acho que vai lhe servir. Em "Data/npc/scripts", anciao.lua: local t = { needItems = {2318, 2174, 2159}, reward = 2090 } 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 msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local iN = t.needItems local n = getItemNameById if msgcontains(msg, 'crystal key') then selfSay('Posso lhe entregar uma crystal key em troca de alguns items: um {'.. n(iN[1]) ..'}, um {'.. n(iN[2]) ..'} e um {'.. n(iN[3]) ..'}, deseja trocar?', cid) talkState[talkUser] = 1 elseif msgcontains(msg, 'yes') then if talkState[talkUser] == 1 then local d = getPlayerItemCount local dP = doPlayerRemoveItem if d(cid, iN[1]) >= 1 and d(cid, iN[2]) >= 1 and d(cid, iN[3]) >= 1 then selfSay('Aqui está sua crystal key.', cid) dP(cid, iN[1], 1) dP(cid, iN[2], 1) dP(cid, iN[3], 1) doPlayerAddItem(cid, t.reward, 1) talkState[talkUser] = 0 else selfSay('Você não tem os items necessários.', cid) talkState[talkUser] = 0 end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Em "Data/npc", anciao.xml: <?xml version="1.0" encoding="UTF-8"?> <npc name="Anciao" script="data/npc/scripts/anciao.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="309" head="57" body="59" legs="40" feet="76" addons="0"/> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|. Em que posso lhe ajudar?"/> </parameters> </npc> ➥ Regras | Seções OTServ | Seções BOT
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.