• 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 Configurating NPC's - Greeting outside npc window

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

I finnaly decided I have to setup some npcs in my server :D
I've been scrolling through the forums but can't really seem to find a way to make my npcs talk within the npc window but still say hi/bye in the regular window. (I allready made them talk fully in the npc window)

Maybe someone can help me out here?
Thanks in advance.
 
Preferable yes and also move the ingame chat window to the npc chat window. Basicly I want people to fully chat within the npc window but I want people nearby to see when you greet/say bye or run away from an npc.
 
You can add
Code:
selfSay(msg, cid)
On line 328 in function NpcHandler:greet(cid) in the npchandler.lua, this way it will greet in default and npc channel.
 
Added it but just get it 2x in the npc window now and not in the default window.

Code:
    -- Greets a new player.
    function NpcHandler:greet(cid)
        if(cid ~= 0) then
            local callback = self:getCallback(CALLBACK_GREET)
            if(callback == nil or callback(cid)) then
                if(self:processModuleCallback(CALLBACK_GREET, cid)) then
                    local msg = self:getMessage(MESSAGE_GREET)
                    local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
                    msg = self:parseMessage(msg, parseInfo)
                    self:say(msg, cid, true)
                    selfSay(msg, cid)
                else
                    return
                end
            else
                return
            end
        end
        self:addFocus(cid)
    end
 
When I add it like I think you mean it :p (npc scirpts isn't my strong suit atm).
Then the npcs says his greating msg in the npc window and just walks on. Also getting the following error posted below.

npchandler.lua
Code:
//~//
    -- Greets a new player.
    function NpcHandler:greet(cid)
        if(cid ~= 0) then
            local callback = self:getCallback(CALLBACK_GREET)
            if(callback == nil or callback(cid)) then
                if(self:processModuleCallback(CALLBACK_GREET, cid)) then
                    local msg = self:getMessage(MESSAGE_GREET)
                    local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
                    msg = self:parseMessage(msg, parseInfo)
                    self:say(msg, cid, true)
                    self:say(msg)
                else
                    return
                end
            else
                return
            end
        end
        self:addFocus(cid)
    end
//~//

Console:
Code:
[10/07/2015 17:31:31] Lua Script Error: [Npc interface] 
[10/07/2015 17:31:31] data/npc/scripts/temple.lua:onCreatureSay

[10/07/2015 17:31:31] data/npc/lib/npcsystem/npchandler.lua:577: table index is nil
[10/07/2015 17:31:31] stack traceback:
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/npchandler.lua:577: in function 'say'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/npchandler.lua:328: in function 'greet'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/npchandler.lua:491: in function 'onGreet'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/modules.lua:205: in function 'callback'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
[10/07/2015 17:31:31]     data/npc/lib/npcsystem/npchandler.lua:372: in function 'onCreatureSay'
[10/07/2015 17:31:31]     data/npc/scripts/temple.lua:8: in function <data/npc/scripts/temple.lua:8>
 
Also sometimes when i reload my npc's instead restarting the server (I restart always with testing scripts like this just to be sure they are fully loaded).

I'm getting the following error:
Code:
[10/07/2015 17:34:41] Reloaded npcs.
[10/07/2015 17:34:41] Lua Script Error: [Npc interface] 
[10/07/2015 17:34:41] data/npc/scripts/default.lua:onThink

So maybe I should just replace all my current global npc files?
 
You can use the npc system from TFS 0.2.15: https://otland.net/threads/9-80-9-86-the-forgotten-server-v0-2-15-mystic-spirit.188228/.
For the greet message in default, you can use selfSay instead.
Code:
  -- Greets a new player.
   function NpcHandler:greet(cid)
     if(cid ~= 0) then
       local callback = self:getCallback(CALLBACK_GREET)
       if(callback == nil or callback(cid)) then
         if(self:processModuleCallback(CALLBACK_GREET, cid)) then
           local msg = self:getMessage(MESSAGE_GREET)
           local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
           msg = self:parseMessage(msg, parseInfo)
           self:say(msg, cid, true)
           selfSay(msg)
         else
           return
         end
       else
         return
       end
     end
     self:addFocus(cid)
   end
 
Replaced my entire lib folder with this new one since I seem to be having some other problems with my ncps also.

Anyway this seems to work like a charm on the greeting part.

As second I'm looking for the same on the goodbye part. When the player says bye in either the main default window or the npc window the npc will respond in both windows.
If the player runs away without saying bye the npc will only yell within the default window.
 
Add the same thing in the ungreet part.
Code:
  -- Makes sure the npc un-focuses the currently focused player
   function NpcHandler:unGreet(cid)
     if(not self:isFocused(cid)) then
       return
     end

     local callback = self:getCallback(CALLBACK_FAREWELL)
     if(callback == nil or callback()) then
       if(self:processModuleCallback(CALLBACK_FAREWELL)) then
         local msg = self:getMessage(MESSAGE_FAREWELL)
         local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
         msg = self:parseMessage(msg, parseInfo)
         self:say(msg, cid, true)
         selfSay(msg)
         self:releaseFocus(cid)
       end
     end
   end
If a player walks away it already only talks in default (at least with the 0.2.15 npcsystem).
 
Back
Top