Postado Janeiro 1, 2015 10 anos PROBLEMA: 1º MENSAGEM DO NPC: Após falar o tipo de troféu (bronze/prata/ouro), o "npc" não fala se deseja confirmar a troca do troféu pela gema, ou seja ele já faz a troca após escreve a opção de troféu. 2º FALA DO NPC: O "npc" está repetindo algumas frases de outros npc's, por exemplo tenho um npc chamado "Mary", e ela tem uma fala que é "Venda seus gold ingot aqui!" e o "npc" de troca no caso esse, fala a mesma frase mesmo não sendo programado na script. SOLUÇÃO: 1º MENSAGEM DO NPC: Quero que mande uma mensagem de confirmação após escolher o tipo de troféu (bronze/prata/ouro) Exemplo: #Player: Hi #NPC: Ola |PLAYERNAME|. Seja Bem-Vindo a Sala de Trocas. Eu coleciono {trofeus} de ouro, prata e bronze. E para garantir que todos troquem comigo, eu retribuo dando gemas aleatorias. #Player: troféu #NPC: Acho que você pretende trocar algum troféu por gemas. Qual troféu você pretende trocar comigo: {ouro}, {prata} ou {bronze} #Player: bronze #NPC: Você tem certeza que quer trocar 1 troféu de bronze por 1 gema aleatória? #Player: sim #NPC: Obrigado, aqui estão suas gemas. < AS MENSAGEM QUE EU DESEJO #Player: prata #NPC: Você tem certeza que quer trocar 1 troféu de prata por 2 gema aleatória? < QUE APAREÇA AO FALAR #Player: sim #NPC: Obrigado, aqui estão suas gemas. < O TIPO DE TROFÉU EM TROCA DE GEMAS! #Player: ouro #NPC: Você tem certeza que quer trocar 1 troféu de ouro por 3 gema aleatória? #Player: sim #NPC: Obrigado, aqui estão suas gemas. 2º FALA DO NPC: Quero que fale as frases que foi programado na script, ou seja não fale de outros npc's. Exemplo: #Troque o seu troféu aqui. #Só entendo português, diga oi. #Oi! Troco gemas por troféus! _________________________________________________________________________________________________________________________ Data/npc: <npc name="Josue" script="data/npc/scripts/trofeu.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="133" head="79" body="0" legs="128" feet="128" addons="1"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|. Seja Bem-Vindo a Sala de Trocas. Eu coleciono {trofeus} de ouro, prata e bronze. E para garantir que todos troquem comigo, eu retribuo dando gemas aleatorias."/> </parameters> </npc> Data/npc/scripts: 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 function thinkCallback(cid) local rand = math.random(1,100) if rand == 10 then selfSay('Troque o seu troféu aqui.') -- msg que vai sair do npc end if rand == 11 then selfSay ('Só entendo português, diga oi.') end if rand == 12 then selfSay ('Oi! Troco gemas por trofeús!') end return true end function greetCallback(cid) return true end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local trophy = { ["ouro"] = {3, 5805}, --{Quantidade de items aleatórios, ID do troféu}, ["prata"] = {2, 5806}, ["bronze"] = {1, 5807}, } local items = {2154, 2156, 2158} if msgcontains(msg, "trophy") or msgcontains(msg, "trofeu") then selfSay("Acho que você pretende trocar algum troféu por gemas. Qual troféu você pretende trocar comigo: {ouro}, {prata} ou {bronze}?", cid) talkState[talkUser] = 1 return true elseif talkState[talkUser] == 1 then if trophy[msg:lower()] then local trofeu = trophy[msg:lower()] local id = trofeu[2] if getPlayerItemCount(cid, id) > 0 then for i = 1, trofeu[1] do doPlayerAddItem(cid, items[math.random(#items)], 1) end doPlayerRemoveItem(cid, id, 1) selfSay("Obrigado, aqui estão suas gemas.", cid) talkState[talkUser] = 0 return true else selfSay("Você não possui este troféu.", cid) talkState[talkUser] = 0 return true end else selfSay("Este troféu não existe.", cid) talkState[talkUser] = 0 return true end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:addModule(FocusModule:new()) Espero que entendam oque eu preciso, agradeço muito quem puder me ajudar!
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.