sabrina9292 1 Postado Janeiro 19, 2012 Share Postado Janeiro 19, 2012 (editado) Bom pessoal... To tentando criar um oraculo, so que infelizmente o conteudo sobre npcs na internet e muito vago e por isso ando tendo muitas dificuldades =/ Queria que quando o player falar "hi" com o oraculo, se ele for lvl 7 ou menos, o oraculo dizer " CHILD! COME BACK WHEN YOU HAVE GROWN UP! ", se o player for lvl 8 ou mais o oraculo dizer "Nome do jogador, ARE YOU PREPARED TO FACE YOUR DESTINY?" O script eh este: 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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end local shopModule = ShopModule:new() npcHandler:addModule(shopModule) function creatureSayCallback(cid, types, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local msg = string.lower(msg) if msg == 'yes' then if(getPlayerLevel(cid)) >= 8 then selfSay(getCreatureName(cid)..', ARE YOU PREPARED TO FACE YOUR DESTINY??', cid) talkState[talkUser] = 1 else selfSay('CHILD! COME BACK WHEN YOU HAVE GROWN UP!', cid) end elseif talkState[talkUser] == 1 then if msgcontains(msg, 'yes') then selfSay('I WILL BRING YOU TO THE ISLAND OF DESTINY AND YOU WILL BE UNABLE TO RETURN HERE! ARE YOU SURE?', cid) talkState[talkUser] = 2 elseif msgcontains(msg, 'no') then talkState[talkUser] = 0 selfSay('COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 2 then if msgcontains(msg, 'yes') then doPlayerSetTown(cid, 1) doTeleportThing(cid,city1) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) selfSay('SO BE IT!', cid) else if msgcontains(msg, 'no') then selfSay('COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!', cid) talkState[talkUser] = 0 end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) So que quando o player fala hi com ele ele diz: 15:56 The Oracle: Olá, GOD Sabrina! O que o traz aqui? Por favor... Tem como voces me ajudarem? Desde ja... Muito obrigada Editado Janeiro 19, 2012 por sabrina9292 Link para o comentário https://xtibia.com/forum/topic/178545-como-fazer-o-oraculo-dizer-falas-diferentes-dependendo-do-level-do-player-rep/ Compartilhar em outros sites More sharing options...
bepokemon 101 Postado Janeiro 19, 2012 Share Postado Janeiro 19, 2012 (editado) Primeiramente poste o script para que possamos editar. Já o code seria algo mais ou menos assim: if(msgcontains(msg, 'hi') and talkState[talkUser] < 1) then if getPlayerLevel(cid) < 8 then selfSay('CHILD! COME BACK WHEN YOU HAVE GROWN UP!',cid) talkState[talkUser] = 0 return true end selfSay(string.upper(getPlayerName(cid))..', ARE YOU PREPARED TO FACE YOUR DESTINY?',cid) talkState[talkUser] = 1 end Editado Janeiro 19, 2012 por Byerne Link para o comentário https://xtibia.com/forum/topic/178545-como-fazer-o-oraculo-dizer-falas-diferentes-dependendo-do-level-do-player-rep/#findComment-1180557 Compartilhar em outros sites More sharing options...
sabrina9292 1 Postado Janeiro 19, 2012 Autor Share Postado Janeiro 19, 2012 (editado) Primeiramente poste o script para que possamos editar. Já o code seria algo mais ou menos assim: if(msgcontains(msg, 'hi') and talkState[talkUser] < 1) then if getPlayerLevel(cid) < 8 then selfSay('[b]CHILD! COME BACK WHEN YOU HAVE GROWN UP!',cid) talkState[talkUser] = 0 return true end selfSay(string.upper(getPlayerName(cid))..' [/b][b]ARE YOU PREPARED TO FACE YOUR DESTINY?',cid) talkState[talkUser] = 1 end Desculpe me... Nao sei o que me deu, e quase impossivel conseguirem me ajudar se eu nao postar o script ;D Vou testar aqui e falo se deu certo -- edit 01 Nao tenho certeza se fiz a coisa certa, mas eu coloquei seu bloco dentro da funçao function creatureSayCallback(cid, types, msg) So que este bloco que vc me passou so era executado depois que eu ja tinha iniciado a conversa com o npc, ou seja, eu tinha que falar hi duas vezes pra dar certo... Talvez tenha um jeito de por o bloco antes da funçao, so que nao consegui =/ Mas de qualquer forma, levou meu rep+ Editado Janeiro 19, 2012 por sabrina9292 Link para o comentário https://xtibia.com/forum/topic/178545-como-fazer-o-oraculo-dizer-falas-diferentes-dependendo-do-level-do-player-rep/#findComment-1180586 Compartilhar em outros sites More sharing options...
bepokemon 101 Postado Janeiro 19, 2012 Share Postado Janeiro 19, 2012 Primeiramente poste o script para que possamos editar. Já o code seria algo mais ou menos assim: if(msgcontains(msg, 'hi') and talkState[talkUser] < 1) then if getPlayerLevel(cid) < 8 then selfSay('[b]CHILD! COME BACK WHEN YOU HAVE GROWN UP!',cid) talkState[talkUser] = 0 return true end selfSay(string.upper(getPlayerName(cid))..' [/b][b]ARE YOU PREPARED TO FACE YOUR DESTINY?',cid) talkState[talkUser] = 1 end Desculpe me... Nao sei o que me deu, e quase impossivel conseguirem me ajudar se eu nao postar o script ;D Vou testar aqui e falo se deu certo Pelo oque eu entendi o erro não está no script.lua, e sim no arquivo XML. Poste também o conteúdo do mesmo. =) Link para o comentário https://xtibia.com/forum/topic/178545-como-fazer-o-oraculo-dizer-falas-diferentes-dependendo-do-level-do-player-rep/#findComment-1180611 Compartilhar em outros sites More sharing options...
sabrina9292 1 Postado Janeiro 19, 2012 Autor Share Postado Janeiro 19, 2012 Primeiramente poste o script para que possamos editar. Já o code seria algo mais ou menos assim: if(msgcontains(msg, 'hi') and talkState[talkUser] < 1) then if getPlayerLevel(cid) < 8 then selfSay('[b]CHILD! COME BACK WHEN YOU HAVE GROWN UP!',cid) talkState[talkUser] = 0 return true end selfSay(string.upper(getPlayerName(cid))..' [/b][b]ARE YOU PREPARED TO FACE YOUR DESTINY?',cid) talkState[talkUser] = 1 end Desculpe me... Nao sei o que me deu, e quase impossivel conseguirem me ajudar se eu nao postar o script ;D Vou testar aqui e falo se deu certo Pelo oque eu entendi o erro não está no script.lua, e sim no arquivo XML. Poste também o conteúdo do mesmo. =) <?xml version="1.0" encoding="UTF-8"?> <npc name="The Oracle" script="The Oracle.lua" walkinterval="0" floorchange="0"> <health now="100" max="100"/> <look typeex="1448" corpse="3128"/> </npc> Acredito que nao seja aqui... Imagino que seja pq os npcs do meu ot estao configurador para dizer a mesma coisa quando alguem diz hi, eu teria que tornar este npc excessao Link para o comentário https://xtibia.com/forum/topic/178545-como-fazer-o-oraculo-dizer-falas-diferentes-dependendo-do-level-do-player-rep/#findComment-1180632 Compartilhar em outros sites More sharing options...
Posts Recomendados