• 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] DoNpcTalkAlot sending messages to every player in range

Glecko

Veteran OT User
Joined
Aug 21, 2007
Messages
1,054
Reaction score
270
Location
Spain
I have been using the function doNpcTalkAlot, but I have stummbled upon two problems.
The first one is that if I walk away, the NPC will continue talking.
The second one, everytime the NPC talks, every player in talking range (3 sqm) recieves the message in the NPC window instead of just the player it is inteded to.

If anybody could help me, I would apreciate it a lot :)

Here are the functions I have in npchandler.lua and npc.lua

Code:
function doCreatureSayWithDelay(cid,text,type,delay,e,pcid)
        if delay<=0 then
                doCreatureSay(cid,text,type, false,pcid)
        else
                local func=function(pars)
                        doCreatureSay(pars.cid,pars.text,pars.type, false,pars.pcid)
                        pars.e.done=TRUE
                end
                e.done=FALSE
                e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e,pcid=pcid})
        end
end

function doNPCTalkALot(msgs,interval,pcid)
        local e={}
        local ret={}
        if interval==nil then interval=10000 end --10 seconds is default time between messages
                for aux=1,table.getn(msgs) do
                e[aux]={}
                doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_FROM_NPC,(aux-1)*interval,e[aux],pcid)
                table.insert(ret,e[aux])
        end
        return(ret)
end
 
Back
Top