Ir para conteúdo

Featured Replies

Postado

Olá pessoal.

 

Eu quero fazer um npc que faz uma conversa continua com o jogador...Ai vai uma parte do script que to usando atualmente pro npc:

 

if msgcontains(msg, 'quest') and getPlayerStorageValue(cid, storage) == -1 then
    
       selfSay("My sword was robbed by a strange guy...I followed him until the Dragon Island's teleport. I'm too old to fight against dragons.", cid)
       selfSay("I'm sure he is still there. If you want to help an old man, please take my precious sword back! Can you do it? ", cid)
       setPlayerStorageValue(cid, storage, 1)

 

O que eu quero saber é qual estrutura/comando eu uso pra continuar a conversa após o jogador dizer "yes" e aceitar a tarefa.

 

Por exemplo: Após o jogador dizer yes o npc agradece e deseja boa sorte.

 

Obrigado e agradeço desde já.

Postado

Se for TFS 1.x+, geralmente se usa npcTopic que é uma tabela que fica salva no script do NPC.
Ex:

if msgcontains(msg, 'yes') and npcTopic[cid] == 1 then
    npcHandler:say('Good luck!', cid)
    npcTopic[cid] = 0
end



 

Caso seja uma versão mais antiga, se usa o talkState.
Ex:

if msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
    selfSay('Boa sorte!', cid)
    talkState[talkUser] = 0
end

The corrupt fear us.

The honest support us.

The heroic join us.

Postado
  • Autor

Uso o TFS 0.3.6 e no caso o código ficou assim

 

 

if msgcontains(msg, 'quest') and getPlayerStorageValue(cid, storage) == -1 then

    
       selfSay("My sword was robbed by a strange guy...I followed him until the Dragon Island's teleport. I'm too old to fight against dragons.", cid)
       selfSay("I'm sure he is still there. If you want to help an old man, please take my precious sword back! Can you do it?", cid)
        talkState[talkUser] = 1
       if(msgcontains(msg, 'yes')) and (talkState[talkUser] == 1 )then
         selfSay('Thanks! Good luck. He is fast and strong so be careful.', cid)
         talkState[talkUser] = 0
         setPlayerStorageValue(cid, storage, 1)

 

O npc continua funcionando, porém quando eu falo o yes ele não responde nada. Preciso colocar mais alguma coisa ou tem alguma coisa errada?

Postado
  • Autor

Aí ta o script. O que tem mais abaixo disso é só o resto da minha quest, acho que não tem necessidade de por.

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local storage = 1111

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




if msgcontains(msg, 'strange things') then
selfSay('I saw demons here! I think they wanted something with that strange pillar and those energized stones!', cid)
selfSay('But no one believed the old Trokr! Tsc tsc!', cid)
end

if msgcontains(msg, 'quest') and getPlayerStorageValue(cid, storage) == -1 then
    
       selfSay("My sword was robbed by a strange guy...I followed him until the Dragon Island's teleport. I'm too old to fight against dragons.", cid)
       selfSay("I'm sure he is still there. If you want to help an old man, please take my precious sword back! Can you do it?", cid)
        talkState[talkUser] = 1
       if(msgcontains(msg, 'yes')) and (talkState[talkUser] == 1 )then
         selfSay('Thanks! Good luck. He is fast and strong so be careful.', cid)
         talkState[talkUser] = 0
         setPlayerStorageValue(cid, storage, 1)
       
end
end    

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo