• 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!

[npc] Problem with delay

tarjei

Necronian Engineer
Joined
May 25, 2008
Messages
505
Reaction score
126
Location
Poland
I have a problem with delay I made with Ispiro help.

When 1 player say to npc a keyword then everything is fine..
But when more players talk to npc in the same time:
When 1 player say a keyword delay starts..
When 2nd players talk to npc, npc change target and talks to this 2nd player..

I tried to explain it clear and I hope you know what I mean.

Ohh and here is code with delay:
Code:
function onThink()				npcHandler:onThink()
 if isPlayer(focus) == TRUE then

	ts = getPlayerStorageValue(focus, id)

	if ts == 30 and (os.clock() - time) > 5 then
		npcHandler:say('who manage to master the test are granted the title of an honorary barbarian and the respect of our people 

... ', focus)
		talk_start = os.clock()
		talkset(focus,id,31)
	end
	if ts == 31 and (os.clock() - talk_start) > 5 then
		npcHandler:say('Are you willing to take {the} {barbarian} {test}? ', focus)
		talk_start = os.clock()
		talkset(focus,id,3)
	end
--------------------------------------------------------------------------------------
end

Thank you for any help. =]

@PS I used SV except talk_state beacouse i though it will solve the problem
 
Last edited:
for example, both players are writing "hi" to an nPC at the same time,
the first one says hi > thais
the second one says "yes" and npc brings him to the thais :D
 
No it is like this

Code:
hi >> barbarian test
npc say tekst1
        tekst2
        tekst3

But while delaying second player say 'barbarian test' to npc
(For example npc was delaying text 2.) then npc stop delaying on text 2 for first player and start delaying from beginning for next player.. :pP I hope now it is more clearly xD
 
*REFRESH*

Hmm its working but not as we wanted xD
Code:
11:09 Asrak: tekst1
11:09 Isimov: tekst2
11:09 Markwin: tekst3

Three random npc's talk these text's :/

@edit
I Tried to use this

delayedSay(text)
delayedSay(text2, 1000)
delayedSay(text3, 2000)

function say(param)
selfSay(text)
doCreatureSay(param.cid, param.text, 1)
end

function delayedSay(text, delay)
local delay = delay or 0
local cid = getNpcCid()
addEvent(say, delay, {cid = cid, text = text})
end

But npc is saying in default channel :(
 
Last edited:
Code:
	function say(param)
	          if(not npcHandler:isFocused(cid)) then
      	      
			npcHandler:say(param.text, focus)

		  end
        return FALSE
       end
       function delayedSay(text, delay)
			local delay = delay or 0
			local nid = getNpcCid()
			addEvent(say, delay, {cid = cid, text = text})


       end

I used this but delay still is working for 1 person.. when second will talk something to npc, npc is changind target :/

I dont realy understand why it wont work ;/

Usage:
delayedSay("text", delay)
 
Last edited:
Try...
Code:
function say(param)
	selfSay(param.text, cid)
end

function delayedSay(text, delay)
	local delay = delay or 0
	addEvent(say, delay, {text = text}, cid)
end

or

Code:
function say(param)
	selfSay(param.text, cid)
end

function delayedSay(text, delay)
	local delay = delay or 0
	addEvent(say, delay, {text = text})
end
 
Last edited:
Both doesnt work at all ;/

Npc doesnt respond now ..
In my opinion you cant use 'cid' in function npchadler:say, only if there is 'focus' instead 'cid' then npc respond..
My script works but when two players talk in the same time, then problems start
 
Last edited:
Back
Top