• 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+ npc responds "hi" by keyword tfs 1.5 772 nekiro

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
930
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
Hi Guys
I would like to know how do I make the npc respond only by keywords. like this one for example.
I realized that there are many npcs of tibia global that only respond by keyword. and that made me curious to know how to configure one.

XML:
Notes: Nezil and his sister Bezil buy and sell equipment for adventurers. You need to say "Hi Nezil" to talk to her, not just "Hi".


XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nezil" script="Nezil.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="160" head="115" body="78" legs="116" feet="57" addons="0"/>
<parameters>
        <parameter key="shop_buyable" value="shovel,2554,50;fishing rod,2580,150;rope,2120,50;backpack,2003,20;bag,1996,5;pick,2553,50;scythe,2550,50;machete,2420,40;torch,2050,2" />
        <parameter key="shop_sellable" value="rope,2120,8;" />
        <parameter key="message_greet" value="Hiho, |PLAYERNAME|. We sell equipment of all kinds."/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|."/>
        <parameter key="message_walkaway" value="Good bye, |PLAYERNAME|." />
</parameters>
</npc>
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

npcHandler:addModule(FocusModule:new())
 
Solution
show this
the npc doesn't answer me in "hi nezil", but when I say hi he didn't answer, 50% working.
i copy script of queen eloise and repeat

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

function greetCallback(cid)
    Topic[cid] = 0
    return true
end

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
--keywordHandler:addKeyword({'uniform'}, StdModule.say...
u ahve 3 options:
first:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Obi" walkinterval="1100" access="3" floorchange="0" script="rook_items.lua">
    <health now="100" max="100"/>
    <look type="128" head="39" body="63" legs="96" feet="38" addons="0"/>
    <parameters>
       
        <parameter key="message_greet" value="Hello, hello, |PLAYERNAME|! Please come in, look, and buy!"/>
        <parameter key="message_placedinqueue" value="Please stand in line |PLAYERNAME|. I'll be with you in a moment."/>
        <parameter key="message_farewell" value="Bye, bye."/>
             
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="how are you;selling;job;name;help;monster;dungeon;sewer;king;seymour;hyancinth;dallheim;amber;willie;bug;stuff;tibia;sam;thais;wares;offer;weapons;armors;helmets;shields;equipments;do you sell;do you have;pick;time;" />
       
        <parameter key="keyword_reply1" value="I am fine, I am fine. I'm so glad to have you here as my customer." />
        <parameter key="keyword_reply2" value="I sell much, much indeed. Just read the blackboards for my awesome wares or just ask me." />
        <parameter key="keyword_reply3" value="I am a merchant, just a humble merchant. What can I do for you?" />
        <parameter key="keyword_reply4" value="My name is Obi, just Obi, the honest merchant. Do you want to buy something?" />
        <parameter key="keyword_reply5" value="I sell stuff to prices that low, that all other merchants would mock at my stupidity." />
        <parameter key="keyword_reply6" value="If you want to challenge the monsters, you need some weapons and armor I sell. You need them definitely!" />
        <parameter key="keyword_reply7" value="If you want to explore the dungeons, you have to equip yourself with the vital stuff I am selling. It's vital in the deepest sense of the word." />
        <parameter key="keyword_reply8" value="Oh, our sewer system is very primitive; so primitive it's overrun by rats. But the stuff I sell is safe from them. Do you want to buy some of it?" />
        <parameter key="keyword_reply9" value="The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!" />
        <parameter key="keyword_reply10" value="He is the head of the local academy. I encouraged him to sponsor you guy, but no one listens to Obi, no one listens to me, as usually." />
        <parameter key="keyword_reply11" value="I don't like him, I dislike him deeply. He is so greedy that he doesn't want to share his profit from life fluids." />
        <parameter key="keyword_reply12" value="What a hero, what a hero." />
        <parameter key="keyword_reply13" value="She is beautiful, very, very beautiful. I hope I can impress her in some way." />
        <parameter key="keyword_reply14" value="This guy does not understand that he should entrust me with the foodbusiness, too. He really should do that and have more time for his farm." />
        <parameter key="keyword_reply15" value="Bugs plague this isle, but my wares are bugfree, totally bugfree." />
        <parameter key="keyword_reply16" value="I sell equipment of all kinds, all kind available on this isle. Just ask me about my wares if you are interested." />
        <parameter key="keyword_reply17" value="One day I will return to the continent as a rich, a very rich man!" />
        <parameter key="keyword_reply18" value="My good old cousin Sam. Oh, how I miss him, how I miss him." />
        <parameter key="keyword_reply19" value="Oh, Thais, I'll be back, I'll be back one day." />
       
        <parameter key="keyword_reply20" value="I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?" />
        <parameter key="keyword_reply21" value="I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?" />
        <parameter key="keyword_reply22" value="I sell spears, rapiers, sabres, daggers, hand axes, axes, and short swords. Just tell me what you want to buy." />
        <parameter key="keyword_reply23" value="I sell jackets, coats, doublets, leather armor, and leather legs. Just tell me what you want to buy." />
        <parameter key="keyword_reply24" value="I sell leather helmets, studded helmets, and chain helmets. Just tell me what you want to buy." />
        <parameter key="keyword_reply25" value="I sell wooden shields and studded shields. Just tell me what you want to buy." />
        <parameter key="keyword_reply26" value="I sell torches, bags, scrolls, shovels, picks, backpacks, sickles, scythes, ropes, fishing rods and sixpacks of worms. Just tell me what you want to buy." />
        <parameter key="keyword_reply27" value="What do you need? I sell weapons, armor, helmets, shields, and equipment." />
        <parameter key="keyword_reply28" value="What do you need? I sell weapons, armor, helmets, shields, and equipment." />
        <parameter key="keyword_reply29" value="I am sorry, we are out of pick axes. I heard that old greedy Al Dee has some but he will charge a fortune." />
       
        <parameter key="keyword_reply30" value="It is about %T. Yes, %T. I am so sorry, I have no watches to sell. Do you want to buy something else?" />
        <parameter key="keyword_reply31" value="I don't buy this garbage!" />
       
        <parameter key="module_shop" value="1"/>
        <parameter key="shop_buyable" value="" />
        <parameter key="shop_sellable" value="" />
    </parameters>
</npc>

second:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'dagger'}, 2379, 2)
shopModule:addSellableItem({'spear'}, 2389, 3)
shopModule:addSellableItem({'hand axe'}, 2380, 4)
shopModule:addSellableItem({'rapier'}, 2384, 5)
shopModule:addSellableItem({'axe'}, 2386, 7)
shopModule:addSellableItem({'hatchet'}, 2388, 25)
shopModule:addSellableItem({'sabre'}, 2385, 12)
shopModule:addSellableItem({'mace'}, 2398, 30)
shopModule:addSellableItem({'short sword'}, 2406, 10)
shopModule:addSellableItem({'sword'}, 2376, 25)
shopModule:addSellableItem({'doublet'}, 2485, 3)
shopModule:addSellableItem({'leather armor'}, 2467, 5)
shopModule:addSellableItem({'chain armor'}, 2464, 40)
shopModule:addSellableItem({'brass armor'}, 2465, 150)
shopModule:addSellableItem({'leather helmet'}, 2461, 3)
shopModule:addSellableItem({'chain helmet'}, 2458, 12)
shopModule:addSellableItem({'studded helmet'}, 2482, 20)
shopModule:addSellableItem({'wooden shield'}, 2512, 3)
shopModule:addSellableItem({'studded shield'}, 2526, 16)
shopModule:addSellableItem({'brass shield'}, 2511, 25)
shopModule:addSellableItem({'plate shield'}, 2510, 40)
shopModule:addSellableItem({'copper shield'}, 2530, 50)
shopModule:addSellableItem({'leather boots'}, 2643, 2)
shopModule:addSellableItem({'rope'}, 2120, 8)



keywordHandler:addKeyword({'pick'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am sorry, we are out of pick axes. I heard that old greedy Al Dee has some but he will charge a fortune."})
keywordHandler:addKeyword({'sell club'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I don't buy this garbage!"})
keywordHandler:addKeyword({'how are you'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am fine, I am fine. I'm so glad to have you here as my customer."})
keywordHandler:addKeyword({'sell'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell much, much indeed. Just read the blackboards for my awesome wares or just ask me."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am a merchant, just a humble merchant. What can I do for you?"})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Obi, just Obi, the honest merchant. Do you want to buy something?"})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell stuff to prices that low, that all other merchants would mock at my stupidity."})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "If you want to challenge the monsters, you need some weapons and armor I sell. You need them definitely!"})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "If you want to explore the dungeons, you have to equip yourself with the vital stuff I am selling. It's vital in the deepest sense of the word."})
keywordHandler:addKeyword({'sewer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Oh, our sewer system is very primitive; so primitive it's overrun by rats. But the stuff I sell is safe from them. Do you want to buy some of it?"})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!"})
keywordHandler:addKeyword({'seymour'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "He is the head of the local academy. I encouraged him to sponsor you guy, but no one listens to Obi, no one listens to me, as usually."})
keywordHandler:addKeyword({'hyacinth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I don't like him, I dislike him deeply. He is so greedy that he doesn't want to share his profit from life fluids."})
keywordHandler:addKeyword({'dallheim'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What a hero, what a hero."})
keywordHandler:addKeyword({'amber'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "She is beautiful, very, very beautiful. I hope I can impress her in some way."})
keywordHandler:addKeyword({'willie'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "This guy does not understand that he should entrust me with the foodbusiness, too. He really should do that and have more time for his farm."})
keywordHandler:addKeyword({'bug'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Bugs plague this isle, but my wares are bugfree, totally bugfree."})
keywordHandler:addKeyword({'stuff'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell equipment of all kinds, all kind available on this isle. Just ask me about my wares if you are interested."})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "One day I will return to the continent as a rich, a very rich man!"})
keywordHandler:addKeyword({'sam'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My good old cousin Sam. Oh, how I miss him, how I miss him."})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Oh, Thais, I'll be back, I'll be back one day."})
keywordHandler:addKeyword({'wares'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?"})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?"})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell spears, rapiers, sabres, daggers, hand axes, axes, and short swords. Just tell me what you want to buy."})
keywordHandler:addKeyword({'armor'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell jackets, coats, doublets, leather armor, and leather legs. Just tell me what you want to buy."})
keywordHandler:addKeyword({'helmet'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell leather helmets, studded helmets, and chain helmets. Just tell me what you want to buy."})
keywordHandler:addKeyword({'shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell wooden shields and studded shields. Just tell me what you want to buy."})
keywordHandler:addKeyword({'equipment'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell torches, bags, scrolls, shovels, picks, backpacks, sickles, scythes, ropes, fishing rods and worms. Just tell me what you want to buy."})
keywordHandler:addKeyword({'do you sell'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What do you need? I sell weapons, armor, helmets, shields, and equipment."})
keywordHandler:addKeyword({'do you have'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What do you need? I sell weapons, armor, helmets, shields, and equipment."})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "It is about |TIME|. Yes, |TIME|. I am so sorry, I have no watches to sell. Do you want to buy something else?"})

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

or you can use talkactions
 
Have not tested:
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 creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if npcHandler.focuses and not npcHandler:isFocused(cid) then
        npcHandler:say("Hey ".. player:getName() ..", I am busy. Stand in line.")
        return false
    end
  
    if not npcHandler.focuses then
        if (msgcontains(msg, "hi") or msgcontains(msg, "hello")) and msgcontains("nezil") then
            npcHandler:say("Hiho ".. player:getName() ..", Nezil at your service.")
            npcHandler:addFocus(cid)
        else
            npcHandler:say("Uhm, me or my sis', ".. player:getName() .."?")
        end
        return true
    end

    if ((msgcontains(msg, "hi") or msgcontains(msg, "hello")) and msgcontains(msg, "bezil")) or msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
        npcHandler:say("Good bye.")
        npcHandler:releaseFocus(cid)
    end 

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
show this
the npc doesn't answer me in "hi nezil", but when I say hi he didn't answer, 50% working.
i copy script of queen eloise and repeat

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

function greetCallback(cid)
    Topic[cid] = 0
    return true
end

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
--keywordHandler:addKeyword({'uniform'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The uniforms of our guards and soldiers are of unparraleled quality of course."})


function creatureSayCallback(cid, type, msg)
    if (msgcontains(msg, 'hi')) and msgcontains(msg, 'nezil') and (not npcHandler:isFocused(cid)) then
        npcHandler:say('Hiho,' ..getCreatureName(cid).. 'We sell equipment of all kinds.', cid)
        npcHandler:addFocus(cid)
        Topic[cid] = 0
    elseif(not npcHandler:isFocused(cid)) then
        return false
    elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
        npcHandler:say('Farewell, '..getCreatureName(cid)..'!', cid, TRUE)
        Topic[cid] = nil
        npcHandler:releaseFocus(cid)
    end
    return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Last edited:
Solution
Insert
Lua:
msgcontains(msg, 'hi') or
before
Lua:
msgcontains(msg, 'hi')

Like:
Lua:
if (msgcontains(msg, 'hi') or msgcontains(msg, 'hi') and msgcontains(msg, 'nezil')) and (not npcHandler:isFocused(cid)) then
 
Back
Top