Hello, Im using a functions for my npcs when telling long stories. Im not sure who the author of the function(s) is but all credit goes to him.
However I need help modifing this function to set a talkstate once all messages are printed
for example
Npc: I live here (3sec)
Npc: In my house (6sec)
Npc: Im happy here (9sec)
talkstate=5 (10 sec)
this is how the delay and npc text is working inside a script
and here is the function I currently use
So what I need is a function or something similar that sets "talkstate=X" in a configurable way after a set time inside a npc script.
Thanks in advance
//Massen
However I need help modifing this function to set a talkstate once all messages are printed
for example
Npc: I live here (3sec)
Npc: In my house (6sec)
Npc: Im happy here (9sec)
talkstate=5 (10 sec)
this is how the delay and npc text is working inside a script
Code:
local missionX={"","",""}
if msgcontains(msg, 'mission') and quest==2 then
talk_var=doNPCTalkALot(missionX,DELAY)
end
Code:
function doCreatureSayWithDelay(cid,text,type,delay,e)
if delay<=0 then
doCreatureSay(cid,text,type)
else
local func=function(pars)
doCreatureSay(pars.cid,pars.text,pars.type)
pars.e.done=TRUE
end
e.done=FALSE
e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
end
end
--returns how many msgs he have said already
function cancelNPCTalk(events)
local ret=1
for aux=1,table.getn(events) do
if events[aux].done==FALSE then
stopEvent(events[aux].event)
else
ret=ret+1
end
end
events=nil
return(ret)
end
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_SAY,(aux-1)*interval,e[aux])
table.insert(ret,e[aux])
end
return(ret)
end
Thanks in advance
//Massen