• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC does not respond to "bye" properly

dominique120

Science & Reason
Senator
Premium User
Joined
Jun 16, 2013
Messages
3,881
Solutions
3
Reaction score
1,046
Location
Númenor
I'm converting my server from 0.3.6 to 0.4 but I'm having some trouble with the NPCs. They respond to "hi" and to "trade" but when I say "bye" the trade window stays open and they dont say anything but will stat walking around like if I had not initiated conversation.

I already replaced the NPC libs but this problem still exists.

Where is the problem here?
 
Because I am polite? I dont know lol. Even when I walk away they dont say anything and the trade window stays open.
 
i hope this can work with you :)
2 ways to do it
first way in your npc.xml
Code:
<interact keywords="bye" focus="0">
      <keywords>farewell</keywords>
      <response text="Good bye. Recommend us, if you were satisfied with our service.">
        <!--
        <action name="script">
          doRemoveCreature(getNpcCid());
        </action>
        -->
      </response>
    </interact>

second way in your npc.lua
Code:
if((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid, true)
        removeFocus(cid)
    end
or
Code:
function onPlayerCloseChannel(cid)
    if(isFocused(cid)) then
        selfSay("Goodbye.")
        removeFocus(cid)
    end
end
or
Code:
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Goodbye.")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
 
do your own research don't trust me but you should probably switch to 1.0 instead of wasting your time doint X to 0.4 convertion
 
Back
Top