Postado Outubro 2, 2014 10 anos Em 02/10/2014 em 05:17, Schiffert disse: se tu quiser, eu marquei a opção melhor resposta, mas não foi, agora foi, você quem sabe em ? Quando você quiser fechar algum tópico relate no próprio tópico ou denuncie-o pedindo para fechar. Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui Muitos querem aquilo que você tem, mas vão desistir quando souberem o preço que você pagou. lu.lukinha absolute@lnetworks.com.br
Postado Outubro 2, 2014 10 anos Autor agora estou com um outro npc aqui com o mesmo erro... alguem pode arrumar? Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if msgcontains(msg, "flou") then if npcHandler.topic[cid] == 0 then npcHandler.topic[cid] = 1 npcHandler:say("Lhnjei gouthn naumpi! I know why you are here. I can explain everything.", cid) else npcHandler:say('I don\'t know what you are talking about.', cid) end elseif msgcontains(msg, 'explain') then if npcHandler.topic[cid] == 1 then npcHandler.topic[cid] = 2 npcHandler:say({ 'By entering this place, you have earned the right to learn what this is all about. This is a long story. Are you sure you want to hear this?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 2 then npcHandler.topic[cid] = 3 npcHandler:say({ 'I was once captain of a ship, the Skyflare. We were traders for King Tibianus and on our way home when we got into a storm. We fought hard to escape the cold grip of the sea. ...', 'I myself did what I could to navigate the Skyflare out of this mess. They depended on me. Me, the navigator. And I succeeded. ...', 'However, when the sea calmed down and the rain was finally gone, we recognised that our ship wouldn't move. It wasn't my fault. ...', 'There was a strong gale and we could already see this island on the horizon. There were seagulls all around the Skyflare to lead us to dry land. But the ship did not move a single inch. It was NOT my fault. ...', 'We dived under the bow and saw that it was stuck right on the tip of a sharp rock. The world below us was treacherous, we could see large underwater mountains and a labyrinthine system of caves and holes. ...', 'Some of my men panicked and hijacked the dinghies to reach the island, others tried to swim. I remained on the ship. It was not my FAULT. It was not. ...', 'Do you have enough, can I stop?' }, cid) elseif msgcontains(msg, 'no') then if npcHandler.topic[cid] == 2 then npcHandler.topic[cid] = 3 npcHandler:say({ 'When none of my men returned, I forced myself to make a decision. Either dying on this dead ship or plunging into the liquid black beneath. ...', 'In my desperation my thoughts fell onto a strange armor - a gift from a trader we dealt with just before the storm. Strange ornaments and fish-like elements decorated this armor. We thought it would fit just perfectly into the captain's cabin. ...', 'He said something like a 'blessed breath' and 'to subdue the drift'. We thought he wanted to sell us worthless decoration and make it look interesting. If I had only listened to what he said. ...', 'I figured that this thing would have something to do with diving or at least protect me from the icy water. I put it on, grabbed a shimmer glower from our storage to light my path and jumped in. ...', 'Do you want me to go on?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 3 then npcHandler.topic[cid] = 4 npcHandler:say({ 'Hmpf. The armor was working. After some time I was surrounded by darkness and could only see as far as my shimmer glower would me allow to. But I didn't feel the cold - I could even breathe through that helmet. ...', 'I dived into the deep black. Across rugged mountains, vast fields of kelp, swarms of strange fish. ...', 'And then I laid my eyes on a creature I have never seen before. I now know that they call themselves Njey. You would call them the 'Creatures of the Deep' or 'Deeplings'. ...', 'I am now convinced that when they first saw me descending in that suit with the light of the shimmer glower encompassing me, they took me for their God King Qjell. And that's when it all started to make sense. Don't you agree?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 4 then npcHandler.topic[cid] = 5 npcHandler:say({ 'Of course you do. And they did, too. They obeyed me. They adored me. They followed me. ...', 'I learnt everything about their culture, their life, their goals and their problems. I found out about vile insect-like creatures inhabiting the surface of the island. And their waiting for the return of Qjell. ...', 'I practically rewrote their history. I WAS THE SECOND COMING. I WAS QJELL. I, THE NAVIGATOR. ...', ' And I navigated them out of their miserable lives. Away from their petty interests. I led them to a greater purpose - to form chaos out of order, to bring back the storm to the seas and to make THINGS MOVE. Do you want to hear the rest as well?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 5 then npcHandler.topic[cid] = 6 npcHandler:say({ 'I control EVERYTHING from this room, navigating the fate of this land for more than a century now. Can you see all these funnels? My voice travels through them and throughout everything down here! ...' }, cid) elseif msgcontains(msg, 'helmet') then if npcHandler.topic[cid] == 6 then npcHandler.topic[cid] = 7 npcHandler:say({ 'NAAAAARGH. If you promise to leave me alone and NOT TO TELL MY SECRET to anyone - you can have one. ...', 'NO! Not the one I'm wearing. I am BOUND to this device. This suit has granted me a longer life. However, once you have spent a certain time with this - there is no turning back if you know what I mean. ... ', 'The armor will merge with your very body. Holding you captive, holding your life in its hands like a ransom. ... ', ' Using Deepling craft and various components from down here, I created several spare helmets - just in case this one gets damaged. If you return that small golden anchor to me, you can have one. Will you? ' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 7 then npcHandler.topic[cid] = 8 player:addOutfit(463) player:addOutfit(464) player:setStorageValue(15434, 1) npcHandler:say({ 'Then take this one. And remember: DO NOT TELL ANYONE ABOUT ME OR ANYTHING YOU HAVE HEARD HERE TODAY. ' }, cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setMessage(MESSAGE_GREET, "Hello there!") npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.") npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.") npcHandler:addModule(FocusModule:new()) PS: não vou criar outro tópico, pq ja tem esse huehue Se Ajudei Rep+ pra mim
Postado Outubro 2, 2014 10 anos (O código está no "Spoiler", se quiser entender o que você errou leia abaixo) Mesmo erro que o anterior. Vário elseifs iguais, logo nunca vai passar do primeiro. Ajuda bastante para você pode procurar erros se você identar o código, fica mais perceptível o que cada bloco do código faz. O que estou falando de vários elseif iguais é isso que você está fazendo: if msgconstains(msg, 'yes') then -- Código elseif msgcontains(msg, 'yes') then -- Segundo Código end Se você fizer isso, ele nunca vai entrar no bloco do "Segundo Código", sempre parando no primeiro. Você tem que fazer assim, por exemplo: if msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 1 then -- Código elseif npcHandler.topic[cid] == 2 then -- Segundo Código end end Lembrando que os if npcHandler.topic tem que ser elseif, se não o player pode falar um yes e acabar percorrendo o diálogo inteiro do npc sem querer. Ah, e nos seus dois códigos agora o player pode pegar o item várias vezes apenas repetindo "yes", é bom você por uma restrição nos ifs para isso não acontecer. Nos dois códigos eu tomei a liberdade e fiz isso, adicionando o "and player:getStorageValue(value) ~= 1" E quando o player já tem esse storage e mesmo assim falar "yes" é bom você fazer o npc falar algo tipo "Você já esteve aqui" ou "Você já aceitou a quest" e derivados, para o player não ficar no vento sem saber se ele pegou tudo que podia ou não. Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if msgcontains(msg, "flou") then if npcHandler.topic[cid] == 0 then npcHandler.topic[cid] = 1 npcHandler:say("Lhnjei gouthn naumpi! I know why you are here. I can explain everything.", cid) else npcHandler:say('I don\'t know what you are talking about.', cid) end elseif msgcontains(msg, 'explain') then if npcHandler.topic[cid] == 1 then npcHandler.topic[cid] = 2 npcHandler:say({ 'By entering this place, you have earned the right to learn what this is all about. This is a long story. Are you sure you want to hear this?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 2 then npcHandler.topic[cid] = 3 npcHandler:say({ 'I was once captain of a ship, the Skyflare. We were traders for King Tibianus and on our way home when we got into a storm. We fought hard to escape the cold grip of the sea. ...', 'I myself did what I could to navigate the Skyflare out of this mess. They depended on me. Me, the navigator. And I succeeded. ...', 'However, when the sea calmed down and the rain was finally gone, we recognised that our ship wouldn't move. It wasn't my fault. ...', 'There was a strong gale and we could already see this island on the horizon. There were seagulls all around the Skyflare to lead us to dry land. But the ship did not move a single inch. It was NOT my fault. ...', 'We dived under the bow and saw that it was stuck right on the tip of a sharp rock. The world below us was treacherous, we could see large underwater mountains and a labyrinthine system of caves and holes. ...', 'Some of my men panicked and hijacked the dinghies to reach the island, others tried to swim. I remained on the ship. It was not my FAULT. It was not. ...', 'Do you have enough, can I stop?' }, cid) elseif npcHandler.topic[cid] == 4 then npcHandler.topic[cid] = 5 npcHandler:say({ 'Of course you do. And they did, too. They obeyed me. They adored me. They followed me. ...', 'I learnt everything about their culture, their life, their goals and their problems. I found out about vile insect-like creatures inhabiting the surface of the island. And their waiting for the return of Qjell. ...', 'I practically rewrote their history. I WAS THE SECOND COMING. I WAS QJELL. I, THE NAVIGATOR. ...', ' And I navigated them out of their miserable lives. Away from their petty interests. I led them to a greater purpose - to form chaos out of order, to bring back the storm to the seas and to make THINGS MOVE. Do you want to hear the rest as well?' }, cid) elseif npcHandler.topic[cid] == 5 then npcHandler.topic[cid] = 6 npcHandler:say({ 'I control EVERYTHING from this room, navigating the fate of this land for more than a century now. Can you see all these funnels? My voice travels through them and throughout everything down here! ...' }, cid) elseif npcHandler.topic[cid] == 7 and player:getStorageValue(15434, 1) ~= 1 then npcHandler.topic[cid] = 8 player:addOutfit(463) player:addOutfit(464) player:setStorageValue(15434, 1) npcHandler:say({ 'Then take this one. And remember: DO NOT TELL ANYONE ABOUT ME OR ANYTHING YOU HAVE HEARD HERE TODAY. ' }, cid) end elseif msgcontains(msg, 'no') then if npcHandler.topic[cid] == 2 then npcHandler.topic[cid] = 3 npcHandler:say({ 'When none of my men returned, I forced myself to make a decision. Either dying on this dead ship or plunging into the liquid black beneath. ...', 'In my desperation my thoughts fell onto a strange armor - a gift from a trader we dealt with just before the storm. Strange ornaments and fish-like elements decorated this armor. We thought it would fit just perfectly into the captain's cabin. ...', 'He said something like a 'blessed breath' and 'to subdue the drift'. We thought he wanted to sell us worthless decoration and make it look interesting. If I had only listened to what he said. ...', 'I figured that this thing would have something to do with diving or at least protect me from the icy water. I put it on, grabbed a shimmer glower from our storage to light my path and jumped in. ...', 'Do you want me to go on?' }, cid) elseif msgcontains(msg, 'yes') then if npcHandler.topic[cid] == 3 then npcHandler.topic[cid] = 4 npcHandler:say({ 'Hmpf. The armor was working. After some time I was surrounded by darkness and could only see as far as my shimmer glower would me allow to. But I didn't feel the cold - I could even breathe through that helmet. ...', 'I dived into the deep black. Across rugged mountains, vast fields of kelp, swarms of strange fish. ...', 'And then I laid my eyes on a creature I have never seen before. I now know that they call themselves Njey. You would call them the 'Creatures of the Deep' or 'Deeplings'. ...', 'I am now convinced that when they first saw me descending in that suit with the light of the shimmer glower encompassing me, they took me for their God King Qjell. And that's when it all started to make sense. Don't you agree?' }, cid) end elseif msgcontains(msg, 'helmet') then if npcHandler.topic[cid] == 6 then npcHandler.topic[cid] = 7 npcHandler:say({ 'NAAAAARGH. If you promise to leave me alone and NOT TO TELL MY SECRET to anyone - you can have one. ...', 'NO! Not the one I\'m wearing. I am BOUND to this device. This suit has granted me a longer life. However, once you have spent a certain time with this - there is no turning back if you know what I mean. ... ', 'The armor will merge with your very body. Holding you captive, holding your life in its hands like a ransom. ... ', ' Using Deepling craft and various components from down here, I created several spare helmets - just in case this one gets damaged. If you return that small golden anchor to me, you can have one. Will you? ' }, cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setMessage(MESSAGE_GREET, "Hello there!") npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.") npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.") npcHandler:addModule(FocusModule:new())
Postado Outubro 2, 2014 10 anos Autor entendi, muito obrigado pela explicação adequada, mas em, no caso do addon que este npc dá, o player só irá falar com ele uma vez na vida vou arrumar um action que entra na sala só uma vez isso é facil.. mas e esse seu spoiler é o script funcional correto ? mas cara, mesmo assim, se eu fizer só elseif npcHandler.topic[cid] == 2 then -- Segundo Código endend ele não vai pegar a segunda parte do código com a mesma palavra da primeira parte no exemplo ali... "yes"... tem que ser words diferentes Editado Outubro 2, 2014 10 anos por Schiffert (veja o histórico de edições) Se Ajudei Rep+ pra mim
Postado Outubro 2, 2014 10 anos Em 02/10/2014 em 16:53, Schiffert disse: entendi, muito obrigado pela explicação adequada, mas em, no caso do addon que este npc dá, o player só irá falar com ele uma vez na vida vou arrumar um action que entra na sala só uma vez isso é facil.. mas e esse seu spoiler é o script funcional correto ? mas cara, mesmo assim, se eu fizer só elseif npcHandler.topic[cid] == 2 then -- Segundo Código end end ele não vai pegar a segunda parte do código com a mesma palavra da primeira parte no exemplo ali... "yes"... tem que ser words diferentes Desculpa, não entendi direito sua duvida. Você quis dizer que ele não vai entrar em "Segundo Código" com a keyword 'yes'? Se for o caso, ele deverá entrar se você na primeira parte mudar o npc.Handler.topic[cid] para 2 e ele falar 'yes' novamente.
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.