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

Solved TFS [0.4] Npc "bye" problem

Sun

Knowledge is power - France is bacon
Joined
Jan 26, 2015
Messages
333
Solutions
22
Reaction score
244
When I say "bye" to an npc they just release focus and don't reply even if I add something like "elseif(msgcontains(msg, 'bye')) then
selfSay('Farewell '.. getCreatureName(cid) ..'', cid)"

The only way I've been able to get a response is by adding this line
"keywordHandler:addKeyword({'bye'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Farewell |PLAYERNAME|.'})"
however when that is added it won't release focus.

Trying to find a solution that will both reply and release focus, thanks.
 
Did you try to put into XML
Code:
<parameter key="message_farewell" value="Good bye."/>

Or
Code:
npcHandler:say("Good bye.", 1)
Maybe it could work with cid instead of 1.

Alternative
Code:
if (msgcontains(msg:lower(),'bye') or msgcontains(msg:lower(),'farewell')) then
  npcHandler:onFarewell(cid)

Another option:
Code:
FOCUS_FAREWELLSWORDS = {'bye', 'farewell', 'see ya'}
self.npcHandler = handler
    for i, word in pairs(FOCUS_FAREWELLSWORDS) do
       local obj = {}
       table.insert(obj, word)
       obj.callback = FOCUS_FAREWELLSWORDS.callback or FocusModule.messageMatcher
       handler.keywordHandler:addKeyword(obj, FocusModule.onFarewell, {module = self})
     end
 
Thanks for the reply.
It came to me that the problem was rather simple since the npc would release focus when saying "bye" it had to be in the function.
I found it in npchandler.lua had to change self:say(msg, cid) to selfSay(msg, cid)
 
Back
Top