• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Support] My demon oak npc doesn't work..

HolmaN

Banned User
Joined
Jun 4, 2007
Messages
1,682
Reaction score
4
Location
Göteborg, Sweden.
Well, I've been trying to solove this myself, but with no result, since I'm as worthless as I am.

The problem is: The npc takes the normal axe and 1k, but doesn't give you the hallowed axe. Is there anyone who can help me to add it?


Code:
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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


    if msgcontains(msg, 'demon oak') then
        if getPlayerStorageValue(cid, 15006) <= 4 and getPlayerStorageValue(cid, 15005) == -1 then
            selfSay('You need to know the exactly location, go local and research some more...' ,cid)
        elseif getPlayerStorageValue(cid, 15006) == 3 and getPlayerStorageValue(cid, 15005) == -1 then
            selfSay('Have you found the demon oak ? To kill this monster you need to get a {Hallowed Axe}. Would you like one?', cid)
            talkState[talkUser] = 1
        elseif getPlayerStorageValue(cid, 15005) == 3 then
            selfSay('Go defeat demon oak. Catch me when you\'re done.', cid)
            talkState[talkUser] = 0
        elseif getPlayerStorageValue(cid, 15005) == 7 then
            selfSay('I can\'t believe you really defeat the demon oak. You may now get your reward. A tip... Search near the cemitery.', cid)
            setPlayerStorageValue(cid,15005,8)
            talkState[talkUser] = 0
        else
            selfSay('Have you found the demon oak ? To kill this monster you need to get a {Hallowed Axe}. Would you like one?', cid)
        end

    elseif msgcontains(msg, 'hallowed axe') then
        if getPlayerStorageValue(cid, 15005) == -1 then
                selfSay('I can forge you one, but then I need you to get mem{1000 gold coins} and a {axe}. Are you interested?', cid)
                talkState[talkUser] = 1
        elseif getPlayerStorageValue(cid, 15005) == 1 then
                selfSay('Great. Do you have 1000 gold coins to give me ?.', cid)
                talkState[talkUser] = 2
        elseif getPlayerStorageValue(cid, 15005) == 2 then
                selfSay('Great. Now do you have an {axe} to give me ?.', cid)
                talkState[talkUser] = 3
            end
    
    elseif msgcontains(msg, 'hugo') then
        selfSay('Ah, the curse of the Plains of Havoc, the hidden beast, the unbeatable foe. I\'ve been living here for years and I\'m sure this is only a {myth}.', cid)
        talkState[talkUser] = 4
        
    elseif talkState[talkUser] == 4 then
        if msgcontains(msg, 'myth') then
            selfSay('There are many tales about the fearsome Hugo. It\'s said it\'s an abnormality, accidentally created by {Yenny the Gentle}. It\'s half demon, halfsomething else and people say it\'s still alive after all these years.', cid)
            talkState[talkUser] = 5
        end
    
    elseif talkState[talkUser] == 5 then
        if msgcontains(msg, 'yenny the gentle') then
            selfSay('Yenny, known as the Gentle, was one of the most powerful wielders of magic in ancient times. She was known throughout the world for her mercy and kindness.', cid)
            setPlayerStorageValue(cid,15200,1)
        end
    
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'yes') then
                selfSay('Great. You have 1000 gold coins to give me ?.', cid)
                setPlayerStorageValue(cid,15005,1)
                talkState[talkUser] = 2
                else
                selfSay('Ok.', cid)
        end

    elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'yes') then
            if(doPlayerRemoveMoney(cid, 1000) == TRUE) then
                selfSay('Great. Now you have a {axe} to me ?.', cid)
                setPlayerStorageValue(cid,15005,2)
                talkState[talkUser] = 3
                else
                selfSay('Ok.', cid)
            end
        end

    elseif talkState[talkUser] == 3 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid,2386,1) == 1 then
                selfSay('Great. Now go and defeat a Demon Oak. Later report me.', cid)
                doPlayerAddItem(cid,8293,1)
                setPlayerStorageValue(cid,15005,3)
                talkState[talkUser] = 3
                else
                selfSay('Ok.', cid)
            end
        end

    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Try this
Code:
  local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if (not npcHandler:isFocused(cid)) then
        return false
    end

        if msgcontains(msg, 'hallowed axe') then
                npcHandler:say('Do you want to buy a Hallowed Axe from me?', cid)
                talk_state = 1
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
                local price = 1000
            if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then
                if doPlayerRemoveMoney(cid, price) == true then
                    npcHandler:say('Here you are. You can now defeat the demon oak with this axe.', cid)
                    doPlayerRemoveItem(cid, 2386, 1)
                    doPlayerAddItem(cid, 8293, 1)
                    talk_state = 0
                end
            else
                npcHandler:say('I need an axe and ' .. price .. ' gold coins to make you a {hallowed axe}.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'demon oak') then
                npcHandler:say('Did you defeat the demon oak?', cid)
                talk_state = 2
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerStorageValue(cid, 35700) == 1 then
                npcHandler:say('Good job!', cid)
                doPlayerSetStorageValue(cid, 35700, 2)
                talk_state = 0
            else
                npcHandler:say('Go defeat the demon oak first.', cid)
                talk_state = 0
            end
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Ok thanks.', cid)
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
That's just a copy of franks. I'd like mine to work. Thanks anyway mate.
:o?
Code:
  local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if (not npcHandler:isFocused(cid)) then
        return false
    end

        if msgcontains(msg, 'hallowed axe') then
                npcHandler:say('Do you want to buy a Hallowed Axe from me?', cid)
                talk_state = 1
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
                local price = 1000
            if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then
                if doPlayerRemoveMoney(cid, price) == true then
                    npcHandler:say('Here you are. You can now defeat the demon oak with this axe.', cid)
                    doPlayerRemoveItem(cid, 2386, 1)
                    doPlayerAddItem(cid, 8293, 1)
                    talk_state = 0
                end
            else
                npcHandler:say('I need an axe and ' .. price .. ' gold coins to make you a {hallowed axe}.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'demon oak') then
                npcHandler:say('Did you defeat the demon oak?', cid)
                talk_state = 2
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerStorageValue(cid, 35700) == 1 then
                npcHandler:say('Good job!', cid)
                doPlayerSetStorageValue(cid, 35700, 2)
                talk_state = 0
            else
                npcHandler:say('Go defeat the demon oak first.', cid)
                talk_state = 0
            end
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Ok thanks.', cid)
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Back
Top