• 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!

TFS 1.X+ TFS 1.5 7.72 npc give key for money

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
881
Solutions
7
Reaction score
122
Location
Brazil
YouTube
caruniawikibr
hello I would like to know how I do it for an npc, in the middle of the conversation, give me a key and withdraw 500 gold for example.



Lua:
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 greetCallback(cid)
        npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|! What can I do for you?")
    return true
end


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

        if msgcontains(msg, "netlios") then   
                npcHandler:say({
                    "That fool! His book is nothing but a hoax! At least I believe that. Or did you find an answer to my questions?"
                }, cid)
                npcHandler.topic[cid] = 1
            return true
        end
            if npcHandler.topic[cid] == 1 then
                if msgcontains(msg, "yes") then   
                        npcHandler:say({
                            "You can't even say 'yes' or 'no'. You are not worth talking to me!"
                        }, cid)
                        npcHandler.topic[cid] = 2
                    return true
                end
            end
                if npcHandler.topic[cid] == 2 then
                    if msgcontains(msg, "yes") then   
                            npcHandler:say({
                                "By the way, I'd like a donation for my temple. Are 500 gold pieces ok?"
                            }, cid)
                            npcHandler.topic[cid] = 3
                        return true
                    end
                end
                    if npcHandler.topic[cid] == 3 then
                        if msgcontains(msg, "yes") then   
                                npcHandler:say({
                                    "Thank you very much. Now, name me the first person in alphabetical order, his age, his fate, and how long he was on his journeys!"
                                }, cid)
                                npcHandler.topic[cid] = 4
                            return true
                        end
                    end
                        if npcHandler.topic[cid] == 4 then
                            if msgcontains(msg, "anaso") then   
                                    npcHandler:say({
                                        "Hmmm, maybe. What can you tell me about the second adventurer?"
                                    }, cid)
                                    npcHandler.topic[cid] = 5
                                return true
                            end
                        end
                            if npcHandler.topic[cid] == 5 then
                                if msgcontains(msg, "elaeus") then   
                                        npcHandler:say({
                                            "Yes, that might be true. What did you find out about the third man?"
                                        }, cid)
                                        npcHandler.topic[cid] = 6
                                    return true
                                end
                            end
                                if npcHandler.topic[cid] == 6 then
                                    if msgcontains(msg, "gadinius") then   
                                            npcHandler:say({
                                                "Correct again! Hmmmm... I doubt you know anything about the fourth person!"
                                            }, cid)
                                            npcHandler.topic[cid] = 7
                                        return true
                                    end
                                end
                                    if npcHandler.topic[cid] == 7 then
                                        if msgcontains(msg, "heso") then   
                                                npcHandler:say({
                                                    "Yes! Really, how did you figure that out? I bet you don't know anything about the last adventurer!"
                                                }, cid)
                                                npcHandler.topic[cid] = 8
                                            return true
                                        end
                                    end
                                        if npcHandler.topic[cid] == 8 then
                                            if msgcontains(msg, "hestus") then   
                                                    npcHandler:say({
                                                        "That's right! Why didn't I see it? It's obvious, Netlios was right, and his stories are great! Wait, I'll give you something!"
                                                    }, cid)
                                                    npcHandler.topic[cid] = 0
                                                return true
                                            end
                                        end
    return true
end




keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Adrenius.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = ' I\'m a priest of Fafnar.'})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, text = 'What\'s that? You start annoying me.'})
keywordHandler:addKeyword({'fight'}, StdModule.say, {npcHandler = npcHandler, text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs a king? I don\'t.'})
keywordHandler:addKeyword({'priestess'}, StdModule.say, {npcHandler = npcHandler, text = 'I live a solitary life here to meditate and contemplate..'})
keywordHandler:addKeyword({'secret'}, StdModule.say, {npcHandler = npcHandler, text = 'Secrets ... What do you mean?'})
keywordHandler:addKeyword({'sword'}, StdModule.say, {npcHandler = npcHandler, text = 'Swords? Don\'t you have something else to do?'})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, text = 'Treasures? What is a treasure for you?'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs weapons? I never had and i never will have weapons - what for?'})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, text = 'I heard of the library, but I never was very interested in it.'})
keywordHandler:addKeyword({'book'}, StdModule.say, {npcHandler = npcHandler, text = 'Read books, it increases your intelligence and, furthermore, it\'s a great source of inspiration!'})
keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar may burn this city of evil. Its heretical inhabitants and their blasphemous leader are an insult to the gods. Beware! The day of reckoning is at hand!'})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, text = 'Carlin? Don\'t you mean Thais?'})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Even after the death of this swindler Daraman, the descendants of his followers cling to his ignorant teachings.'})
keywordHandler:addKeyword({'daraman'}, StdModule.say, {npcHandler = npcHandler, text = 'The Daramian deserts are much more impressive than this one. Sadly the continent is run over by heretics of all sorts...'})
keywordHandler:addKeyword({'desert'}, StdModule.say, {npcHandler = npcHandler, text = 'Sand, sand and again sand. Sand all over. Yes, I\'d say: it\'s truly a desert!'})
keywordHandler:addKeyword({'tower'}, StdModule.say, {npcHandler = npcHandler, text = 'The tower was built and inhabited by the great sage Jakundaf himself. It\'s a shame that it can be rented nowadays. People have no respect for the past!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'Yyyyess. Yes, it\'s the capital city of Tibia I think.'})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the greatest among the gods.'})
keywordHandler:addKeyword({'farfnar'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the stronger one of the two suns above our world.'})
keywordHandler:addKeyword({'suon'}, StdModule.say, {npcHandler = npcHandler, text = 'Suon is the misguided sibling of the great Fafnar. Suon\'s light turns pale compared to the brightness of Fafnar.'})
keywordHandler:addKeyword({'door'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs doors? Free your mind!'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = 'Time? What is time? A word? A thing? An object?'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, text = 'I can offer you religion and mysticism.'})


npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Adrenius.xml:
XML:
<npc name="Adrenius" script="Adrenius.lua" floorchange="0" walkinterval="3500" speed="100">
    <health now="100" max="100"/>
    <look type="9" head="0" body="0" legs="0" feet="0"/>
    <parameters>
    <parameter key="message_greet" value="Hello, |PLAYERNAME|! What can I do for you?"/>
    <parameter key="message_placedinqueue" value="Can't you see, I am talking to someone else!"/>
    <parameter key="message_walkaway" value="Leave me, I am used to it anyways..."/>
    <parameter key="message_farewell" value="Good bye."/>
    <parameter key="message_idletimeout" value="Good bye."/>
    <parameter key="message_alreadyfocused" value="??"/>
    </parameters>
</npc>


Adrenius.lua:
Lua:
local keywordHandler =...
I am not sure if there's a better method in NPCs but shouldn't you just add.
Lua:
player:removeTotalMoney(500)
player:addItem(KeyID, 1)
or
Lua:
player:removeMoney(500)
player:addItem(KeyID, 1)
After the word you want?
Example:
Lua:
if npcHandler.topic[cid] == 4 then
    if msgcontains(msg, "anaso") then
        npcHandler:say(
            {
                "Hmmm, maybe. What can you tell me about the second adventurer?"
            },
            cid
        )
        player:removeMoney(500)
        player:addItem(KeyID, 1)
        npcHandler.topic[cid] = 5
        return true
    end
end
 
work but no have actionid on key, how to add?
i found
ty


Lua:
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 greetCallback(cid)
        npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|! What can I do for you?")
    return true
end


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

        if msgcontains(msg, "netlios") then   
                npcHandler:say({
                    "That fool! His book is nothing but a hoax! At least I believe that. Or did you find an answer to my questions?"
                }, cid)
                npcHandler.topic[cid] = 1
            return true
        end
            if npcHandler.topic[cid] == 1 then
                if msgcontains(msg, "yes") then   
                        npcHandler:say({
                            "You can't even say 'yes' or 'no'. You are not worth talking to me!"
                        }, cid)
                        npcHandler.topic[cid] = 2
                    return true
                end
            end
                if npcHandler.topic[cid] == 2 then
                    if msgcontains(msg, "yes") then   
                            npcHandler:say({
                                "By the way, I'd like a donation for my temple. Are 500 gold pieces ok?"
                            }, cid)
                            npcHandler.topic[cid] = 3
                        return true
                    end
                end
                    if npcHandler.topic[cid] == 3 then
                        if msgcontains(msg, "yes") then   
                                npcHandler:say({
                                    "Thank you very much. Now, name me the first person in alphabetical order, his age, his fate, and how long he was on his journeys!"
                                }, cid)
                                local key = player:addItem(2088, 1)
                                if key then
                                key:setActionId(3666)
                                player:removeTotalMoney(500)
                                npcHandler.topic[cid] = 4
                            return true
                        end
                        end
                    end
                        if npcHandler.topic[cid] == 4 then
                            if msgcontains(msg, "anaso") then   
                                    npcHandler:say({
                                        "Hmmm, maybe. What can you tell me about the second adventurer?"
                                    }, cid)
                                    npcHandler.topic[cid] = 5
                                return true
                            end
                        end
                            if npcHandler.topic[cid] == 5 then
                                if msgcontains(msg, "elaeus") then   
                                        npcHandler:say({
                                            "Yes, that might be true. What did you find out about the third man?"
                                        }, cid)
                                        npcHandler.topic[cid] = 6
                                    return true
                                end
                            end
                                if npcHandler.topic[cid] == 6 then
                                    if msgcontains(msg, "gadinius") then   
                                            npcHandler:say({
                                                "Correct again! Hmmmm... I doubt you know anything about the fourth person!"
                                            }, cid)
                                            npcHandler.topic[cid] = 7
                                        return true
                                    end
                                end
                                    if npcHandler.topic[cid] == 7 then
                                        if msgcontains(msg, "heso") then   
                                                npcHandler:say({
                                                    "Yes! Really, how did you figure that out? I bet you don't know anything about the last adventurer!"
                                                }, cid)
                                                npcHandler.topic[cid] = 8
                                            return true
                                        end
                                    end
                                        if npcHandler.topic[cid] == 8 then
                                            if msgcontains(msg, "hestus") then   
                                                    npcHandler:say({
                                                        "That's right! Why didn't I see it? It's obvious, Netlios was right, and his stories are great! Wait, I'll give you something!"
                                                    }, cid)
                                                    npcHandler.topic[cid] = 0
                                                return true
                                            end
                                        end
    return true
end




keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Adrenius.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m a priest of Fafnar.'})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, text = 'What\'s that? You start annoying me.'})
keywordHandler:addKeyword({'fight'}, StdModule.say, {npcHandler = npcHandler, text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs a king? I don\'t.'})
keywordHandler:addKeyword({'priestess'}, StdModule.say, {npcHandler = npcHandler, text = 'I live a solitary life here to meditate and contemplate..'})
keywordHandler:addKeyword({'secret'}, StdModule.say, {npcHandler = npcHandler, text = 'Secrets ... What do you mean?'})
keywordHandler:addKeyword({'sword'}, StdModule.say, {npcHandler = npcHandler, text = 'Swords? Don\'t you have something else to do?'})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, text = 'Treasures? What is a treasure for you?'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs weapons? I never had and i never will have weapons - what for?'})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, text = 'I heard of the library, but I never was very interested in it.'})
keywordHandler:addKeyword({'book'}, StdModule.say, {npcHandler = npcHandler, text = 'Read books, it increases your intelligence and, furthermore, it\'s a great source of inspiration!'})
keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar may burn this city of evil. Its heretical inhabitants and their blasphemous leader are an insult to the gods. Beware! The day of reckoning is at hand!'})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, text = 'Carlin? Don\'t you mean Thais?'})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Even after the death of this swindler Daraman, the descendants of his followers cling to his ignorant teachings.'})
keywordHandler:addKeyword({'daraman'}, StdModule.say, {npcHandler = npcHandler, text = 'The Daramian deserts are much more impressive than this one. Sadly the continent is run over by heretics of all sorts...'})
keywordHandler:addKeyword({'desert'}, StdModule.say, {npcHandler = npcHandler, text = 'Sand, sand and again sand. Sand all over. Yes, I\'d say: it\'s truly a desert!'})
keywordHandler:addKeyword({'tower'}, StdModule.say, {npcHandler = npcHandler, text = 'The tower was built and inhabited by the great sage Jakundaf himself. It\'s a shame that it can be rented nowadays. People have no respect for the past!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'Yyyyess. Yes, it\'s the capital city of Tibia I think.'})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the greatest among the gods.'})
keywordHandler:addKeyword({'farfnar'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the stronger one of the two suns above our world.'})
keywordHandler:addKeyword({'suon'}, StdModule.say, {npcHandler = npcHandler, text = 'Suon is the misguided sibling of the great Fafnar. Suon\'s light turns pale compared to the brightness of Fafnar.'})
keywordHandler:addKeyword({'door'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs doors? Free your mind!'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = 'Time? What is time? A word? A thing? An object?'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, text = 'I can offer you religion and mysticism.'})


npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Adrenius.xml:
XML:
<npc name="Adrenius" script="Adrenius.lua" floorchange="0" walkinterval="3500" speed="100">
    <health now="100" max="100"/>
    <look type="9" head="0" body="0" legs="0" feet="0"/>
    <parameters>
    <parameter key="message_greet" value="Hello, |PLAYERNAME|! What can I do for you?"/>
    <parameter key="message_placedinqueue" value="Can't you see, I am talking to someone else!"/>
    <parameter key="message_walkaway" value="Leave me, I am used to it anyways..."/>
    <parameter key="message_farewell" value="Good bye."/>
    <parameter key="message_idletimeout" value="Good bye."/>
    <parameter key="message_alreadyfocused" value="??"/>
    </parameters>
</npc>


Adrenius.lua:
Lua:
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

local fire = Condition(CONDITION_FIRE)
fire:setParameter(CONDITION_PARAM_DELAYED, true)
fire:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
fire:addDamage(25, 9000, -10)

keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Adrenius."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm a priest of Fafnar."})
keywordHandler:addKeyword({'fafnar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Fafnar is the stronger one of the two suns above our world."})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Yyyyess. Yes, it's the capital city of Tibia I think."})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Carlin? Don't you mean Thais?"})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Who needs a king? I don't."})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Who needs weapons? I never had and i never will have weapons - what for?"})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Help? Help? Nothing more? Don't we all demand some help?"})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Time? What is time? A word? A thing? An object?"})
keywordHandler:addKeyword({'sword'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Swords? Don't you have something else to do?"})
keywordHandler:addKeyword({'desert'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Sand, sand and again sand. Sand all over. Yes, I'd say: it's truly a desert!"})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What's that? You start annoying me."})
keywordHandler:addKeyword({'fight'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Leave me alone. I don't want to fight."})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Fafnar is the greatest among the gods."})
keywordHandler:addKeyword({'way'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Way? Which way? I forgot where most ways go to... excuse me."})
keywordHandler:addKeyword({'door'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Who needs doors? Free your mind!"})
keywordHandler:addKeyword({'secret'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Secrets ... What do you mean?"})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Treasures? What is a treasure for you?"})
keywordHandler:addKeyword({'book'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Read books, it increases your intelligence and, furthermore, it's a great source of inspiration!"})
keywordHandler:addKeyword({'gharonk'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Hmmmm... I don't know much about it."})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer you religion and mysticism."})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I heard of the library, but I never was very interested in it."})


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if msgcontains(msg, "netlios") then
        npcHandler:say("This fool! His book is nothing but a hoax! At least I believe that. Or did you find an answer for my questions?", cid)
        npcHandler.topic[cid] = 1

        elseif msgcontains(msg, "anaso") and msgcontains(msg, '41') and msgcontains(msg, 'mother') and msgcontains(msg, '117') and npcHandler.topic[cid] == 3 then
            npcHandler:say("Hmmm, maybe. What can you tell me about the second 'adventurer'?", cid)
            npcHandler.topic[cid] = 4

        elseif msgcontains(msg, "elaeus") and msgcontains(msg, '39') and msgcontains(msg, 'dragon') and msgcontains(msg, '100') and npcHandler.topic[cid] == 4 then
            npcHandler:say("Yes, that might be true. What did you find out about the third man?", cid)
            npcHandler.topic[cid] = 5

        elseif msgcontains(msg, "gadinius") and msgcontains(msg, '42') and msgcontains(msg, 'fire') and msgcontains(msg, '83') and npcHandler.topic[cid] == 5 then
            npcHandler:say("Correct again! Hmmmm... I doubt you know anything about the fourth person!", cid)
            npcHandler.topic[cid] = 6

        elseif msgcontains(msg, "heso") and msgcontains(msg, '40') and msgcontains(msg, 'troll') and msgcontains(msg, '66') and npcHandler.topic[cid] == 6 then
            npcHandler:say("Yes! Really, how did you figure that out? I bet, you don't know anything about the last adventurer!", cid)
            npcHandler.topic[cid] = 7

        elseif msgcontains(msg, "hestus") and msgcontains(msg, '38') and msgcontains(msg, 'poison') and msgcontains(msg, '134') and npcHandler.topic[cid] == 7 then
            local key = player:addItem(2088, 1)
            if key then
                key:setActionId(4023)
            end
            npcHandler:say("That's right! Why didn't I see it? It's obvious, Netlios was right, and his stories are great! Wait, I'll give you something!", cid)
            npcHandler.topic[cid] = 0

    elseif msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 1 then
            npcHandler:say("By the way, I would like a donation for my temple. Are 500 gold ok?", cid)
            npcHandler.topic[cid] = 2
        elseif npcHandler.topic[cid] == 2 then
            if player:removeMoney(500) then
                npcHandler:say("Thank you very much. Now, name me the first person in alphabetical order, his age, his fate, and how long he was on his journeys!", cid)
                npcHandler.topic[cid] = 3
            else
                npcHandler:say("You want to fool me? May Fafnar burn your soul!", cid)
                player:addCondition(fire)
                player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
                Npc():getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
                npcHandler:releaseFocus(cid)
                npcHandler:resetNpc(cid)
            end
        end

    elseif msgcontains(msg, "no") then
        if npcHandler.topic[cid] == 1 then
            npcHandler:say("Oh. So once again I am proved right.", cid)
            npcHandler.topic[cid] = 0
        end

    elseif string.lower(msg) ~= '' then
        if npcHandler.topic[cid] == 1 then
            npcHandler:say("You can't even say 'yes' or 'no'. You are not worth talking to me!", cid)
            npcHandler.topic[cid] = 0
            npcHandler:releaseFocus(cid)

        elseif npcHandler.topic[cid] == 3 then
            npcHandler:say("No, sorry, that doesn't sound correct to me. Maybe you should reconsider your words one more time...", cid)
            npcHandler.topic[cid] = 3

        elseif npcHandler.topic[cid] == 4 then
            npcHandler:say("No, no, no! Think about it, that simply can't be true!", cid)
            npcHandler.topic[cid] = 4

        elseif npcHandler.topic[cid] == 5 then
            npcHandler:say("Hmmmm... well, no. That is not true, it does not fit to the data provided by the books.", cid)
            npcHandler.topic[cid] = 5

        elseif npcHandler.topic[cid] == 6 then
            npcHandler:say("No, sorry. Incorrect...", cid)
            npcHandler.topic[cid] = 6

        elseif npcHandler.topic[cid] == 7 then
            npcHandler:say("Well, and again it was shown: I am right and Netlios is wrong!", cid)
            npcHandler.topic[cid] = 7
        end
    end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Back
Top