• 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 random speaking?

Code:
function onThink()
talk = math.random(1,100)
	if talk == 1 then
		doCreatureSay(getNpcCid(), "Best wands and rods in city!", TALKTYPE_YELL) 
	end
if talk == 50 then
		doCreatureSay(getNpcCid(), "Cheapest magic equipment only here!", TALKTYPE_YELL)
		
	end
end

It may cause NPC to not work. Dunno the reason but still searching solution.

Note. onThink is only method to do this (easier anyways)
 
anyway for me its working but he is not yalling like monsters :D He is writing it on general but I like it!


Slawkens I did like u say and here is error in console (I use 0.3 beta 3):

Code:
[27/01/2009 15:07:26] data/npc/scripts/rooktext.lua:15: attempt to index global 'npcHandler' (a nil value)
[27/01/2009 15:07:26] stack traceback:
[27/01/2009 15:07:26] 	data/npc/scripts/rooktext.lua:15: in function <data/npc/scripts/rooktext.lua:1>
 
On top of the NPC you have:
Code:
function onThink()					npcHandler:onThink()					end
replace it with:
Code:
function onThink()
talk = math.random(1,100)
	if talk == 1 then
		doCreatureSay(getNpcCid(), "Best wands and rods in city!", TALKTYPE_YELL) 
	end
if talk == 50 then
		doCreatureSay(getNpcCid(), "Cheapest magic equipment only here!", TALKTYPE_YELL)
		
	end
npcHandler:onThink()
end
 
lol I know that it shall be in 9th line... but u dont understand me :p Read again my post.

The problem is that first script is working but second not and still same error appear 0.o hows that?:/

Have u checked it?
 
Back
Top