• 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 doNPCTalkALo Problem rep++

Fyruz

★★★★★
Joined
Feb 7, 2009
Messages
556
Reaction score
19
Location
127.0.0.1
Hello everyone. Since im starting to help people, i just want to know why this happens:
When someone else talk to an npc with the function
Lua:
doNPCTalkALot
, the messages appear to everybody else that isnt talking to the npc. It appears in the NPCs channel like if you were talking to the npc. If someone can tell me why and how i can fix it. Thx I will give reputation
 
Lua:
function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end

He is using this one, and it is to make interval between messages when using a lot of text.
 
npc/lib/npcsystem/npchandler.lua

paste this before the last end in: npchandler.lua
Lua:
    function storyTalk(messages, focus, i, self)
        if self:isFocused(focus) then
            selfSay(messages[i], focus)
        end
    end
    
    function NpcHandler:story(messages, focus, storyDelay)
        if self:isFocused(focus) then
            selfSay(messages[1], focus)
            local delay = storyDelay
            for i = 2, #messages do
                addEvent(storyTalk, storyDelay, messages, focus, i, self)
                storyDelay = storyDelay + delay
            end
        end
    end
Usage:
Lua:
    if msgcontains(msg, "cool story brah!") then
        local msg = {"I am ...", "teh coolest dude ... ", "that ever ...", "existed."}
        npcHandler:story(msg, cid, 1000)
    end
 
Last edited:
npc/lib/npcsystem/npchandler.lua

paste this before the last end in: npchandler.lua
Lua:
    function storyTalk(messages, focus, i, self)
        if self:isFocused(focus) then
            selfSay(messages[i], focus)
        end
    end
    
    function NpcHandler:story(messages, focus, storyDelay)
        if self:isFocused(focus) then
            selfSay(messages[1], focus)
            local delay = storyDelay
            for i = 2, #messages do
                addEvent(storyTalk, storyDelay, messages, focus, i, self)
                storyDelay = storyDelay + delay
            end
        end
    end
Usage:
Lua:
    if msgcontains(msg, "cool story brah!") then
        local msg = {"I am ...", "teh coolest dude ... ", "that ever ...", "existed."}
        npcHandler:story(msg, cid, 1000)
    end

Work Perfectly. Thanks
 
Back
Top