Ir para conteúdo

Featured Replies

Postado

galera, to com um erro num npc que estou fazendo...

pq num pedido ali ninguem me ajudou, to tentando me virar....

ele simplesmente não dá o item pro player e também nao fala os textos...

quando eu falo yes pela segunda vez

segue o script.

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, "help") then
if npcHandler.topic[cid] == 0 then
npcHandler.topic[cid] = 1
npcHandler:say("Yeah yeah, you can help me actually. You know, I feel some bad vibes coming out of the earth, recently. I think there's something wrong with the creatures of the deep. Care to join me?", cid)
else
npcHandler:say('I don\'t know what you are talking about.', cid)
end
elseif msgcontains(msg, 'yes') then
if npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 2
npcHandler:say({
'Great, great. There is something going on, you know? I can feel it in my bones. There really are some bad spirits down there. ...',
'See, a long time ago I acquired these nets. They are called soul nets. Do you know what they can do? Neither do I. ...',
'What I know is they vibrate when evil is near. Yeah, vibration man. ...',
'They also let evil glow in a deep red. Glowing red stuff. So next time you go down there, just take one with you and when you find evil spirits - catch them with the net. ...',
'They will vanish in an instant. But - you will have to take care that all bad spirits in the near vicinity vanish almost instantaneously or they will regenerate. ...',
'So you might need some help down there, my friend. Ready to do this?'
}, cid)
end
elseif msgcontains(msg, 'yes') then
if npcHandler.topic[cid] == 2 then
player:setStorageValue(15433, 1)
player:addItem(15433, 1)
npcHandler:say("Good, I hope this will help you keeping the spirits away.", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Hi there |PLAYERNAME|, and welcome to the gray island.")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())

Resolvido por Elwyn

Ir para solução
  • Respostas 14
  • Visualizações 944
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

  • 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

  • Tem um detalhe só, se o player ficar repetindo "yes", o item vai ser removido mais de uma vez. Nada demais, mas que é bom consertar.

Postado
  • Solução

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, "help") then
        if npcHandler.topic[cid] == 0 then
            npcHandler.topic[cid] = 1
            npcHandler:say("Yeah yeah, you can help me actually. You know, I feel some bad vibes coming out of the earth, recently. I think there's something wrong with the creatures of the deep. Care to join me?", cid)
        else
            npcHandler:say('I don\'t know what you are talking about.', cid)
        end
    elseif msgcontains(msg, 'yes') then
        if npcHandler.topic[cid] == 1 then
        npcHandler.topic[cid] = 2
        npcHandler:say({
        'Great, great. There is something going on, you know? I can feel it in my bones. There really are some bad spirits down there. ...',
        'See, a long time ago I acquired these nets. They are called soul nets. Do you know what they can do? Neither do I. ...',
        'What I know is they vibrate when evil is near. Yeah, vibration man. ...',
        'They also let evil glow in a deep red. Glowing red stuff. So next time you go down there, just take one with you and when you find evil spirits - catch them with the net. ...',
        'They will vanish in an instant. But - you will have to take care that all bad spirits in the near vicinity vanish almost instantaneously or they will regenerate. ...',
        'So you might need some help down there, my friend. Ready to do this?'
        }, cid)
        elseif npcHandler.topic[cid] == 2 and player:getStorageValue(15433) ~= 1 then
            player:setStorageValue(15433, 1)
            player:addItem(15433, 1)
            npcHandler:say("Good, I hope this will help you keeping the spirits away.", cid)
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Hi there |PLAYERNAME|, and welcome to the gray island.")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())

 

Você tinha dois elseifs iguais, então o segundo nunca era checado na prática.

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