So I have this problem. I am using the function doNPCTalkALot to make NPC's say different messages with delays.
But whenever I use that function, every player in talking range gets the messages (not just the player meant to get the message) which is very confusing for players.
I have tried this function:
This one too:
Those 2 have the same problem but work. Finally I tried this function:
Which gives me the follwing error:

So my conclusion is... if anybody knows what's the problem, I would be super happy (and give lots of rep++) if you fixed it, but if you have no idea why it's not working, but got a working npchandler.lua (along with the rest of the npcsystem files) I would also appreciate it a lot if you shared it
Thanks in advance!
But whenever I use that function, every player in talking range gets the messages (not just the player meant to get the message) which is very confusing for players.
I have tried this function:
Code:
function NpcHandler:cancelNPCTalk(events)
for aux = 1, #events do
stopEvent(events[aux].event)
end
events = nil
end
function NpcHandler:doNPCTalkALot(msgs, interval, pcid)
if self.eventDelayedSay[pcid] then
self:cancelNPCTalk(self.eventDelayedSay[pcid])
end
self.eventDelayedSay[pcid] = {}
local ret = {}
for aux = 1, #msgs do
self.eventDelayedSay[pcid][aux] = {}
doCreatureSayWithDelay(getNpcCid(), msgs[aux], TALKTYPE_PRIVATE_NP, ((aux-1) * (interval or 10000)) + 1000, self.eventDelayedSay[pcid][aux], pcid)
table.insert(ret, self.eventDelayedSay[pcid][aux])
end
return(ret)
end
This one too:
Code:
function npcDelayedTalk(cid, text, player)
if isNpc(cid) and isPlayer(player) then
doCreatureSay(cid, text, TALKTYPE_PRIVATE_NP, false, player, getThingPos(cid))
end
end
function NpcHandler:doNPCTalkALot(msgs, interval, pcid)
if self.eventDelayedSay[pcid] then
self:cancelNPCTalk(self.eventDelayedSay[pcid])
end
self.eventDelayedSay[pcid] = {}
local ret = {}
for aux = 1, #msgs do
self.eventDelayedSay[pcid][aux] = {}
doCreatureSayWithDelay(getNpcCid(), msgs[aux], TALKTYPE_PRIVATE_NP, ((aux-1) * (interval or 10000)) + 1000, self.eventDelayedSay[pcid][aux], pcid)
table.insert(ret, self.eventDelayedSay[pcid][aux])
end
return(ret)
end
Those 2 have the same problem but work. Finally I tried this function:
Code:
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
Which gives me the follwing error:
So my conclusion is... if anybody knows what's the problem, I would be super happy (and give lots of rep++) if you fixed it, but if you have no idea why it's not working, but got a working npchandler.lua (along with the rest of the npcsystem files) I would also appreciate it a lot if you shared it
Thanks in advance!