• 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 Talkalot problem

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Reaction score
5
Location
Halland - Getinge
Hi, my problem is that when i talk to a npc who have talkalot system all player in npc area get a NPC channel and they see what he says.
Is there a way to solve this?

Thanks in advance!
 
use this script when dont work then your npc script ist buged xD
data/XML/channels.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
	<!-- README:
		0 - dynamic, reserved for guilds
		1 - always acts as Party channel, only "name" tag available
		3 - always acts as Rule Violations channel
		9 - acts as Help channel- clientsided message
		65535 - DO NOT CHANGE THE ID- only "name", "enabled", "active" and "logged" tags available
	 -->
	<channel id="1" name="Party"/>
	<channel id="2" name="Staff" access="3"/>
	<channel id="3" name="Rule Violations" logged="yes"/>
	<channel id="5" name="Game-Chat" level="2"/>
	<channel id="6" name="Trade" level="8" muted="120" conditionId="2" conditionMessage="You may only place one offer in two minutes.">
		<vocation id="1-8"/>
	</channel>
	<channel id="9" name="Help" muted="12" conditionId="2" conditionMessage="You can write here every 12 seconds." logged="yes"/>
	<!-- <channel id="10" name="My Custom Channel"/> -->
	<channel id="65535" name="Private Chat Channel"/>
</channels>
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local Topic = {}
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
 
function greetCallback(cid)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  Topic[talkUser] = 0
    return true
end

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_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local namee = getPlayerName(cid)

	if msgcontains(msg, "arkarra") or msgcontains(msg, "Arkarra") then
		local msgs={
            		"The stampor in the back? She's my friend, but she came to me out of her own free will. I must admit I've never managed to tame any other stampor. ...",
            		"I heard that there's some sort of voodoo magic which would allow you to summon a stampor, but I'm not a voodoo expert, so I wouldn't know.",
            		}
      		doNPCTalkALot(msgs,7052)
		Topic[cid] = 0
	end
	return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

When I asks about Akarra everyone around see the conversation
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
 
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
 
function greetCallback(cid)
	Topic[cid] = nil
	return true
end
 
local function s(cid, text, pid)
	if isNpc(cid) and isPlayer(pid) then
		doCreatureSay(cid, text, TALKTYPE_PRIVATE_NP, false, pid, getThingPos(cid))
	end
end
 
function doNPCTalkALot(msgs, pid, interval)
	interval = interval or 3000
	local cid = getNpcCid()
	for i = 1, #msgs do
		if i == 1 then
			doCreatureSay(cid, msgs[i], TALKTYPE_PRIVATE_NP, false, pid, getThingPos(cid))
		else
			addEvent(s, (i-1)*interval, cid, msgs[i], pid)
		end
	end
end
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'arkarra') or msgcontains(msg, 'Arkarra') then
		doNPCTalkALot({"The stampor in the back? She's my friend, but she came to me out of her own free will. I must admit I've never managed to tame any other stampor. ...","I heard that there's some sort of voodoo magic which would allow you to summon a stampor, but I'm not a voodoo expert, so I wouldn't know."}, cid, 7000)
		Topic[cid] = nil
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
I have tried that script but the NPC only says
"The stampor in the back? She's my friend, but she came to me out of her own free will. I must admit I've never managed to tame any other stampor. ..."
He doesnt say the second line.
Please help me again Cyko =)
 
Back
Top