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

New Chat System

cocoroto

New Member
Joined
Oct 13, 2008
Messages
54
Reaction score
0
Does anyone know how to activate the new NPC CHAT SYSTEM?

When I talk with the NPC, the new npc window doesnt appear, and the NPC doesnt talk in that window either.

Thank you for your help.
 
Yeah...
Ex:
Defalt Channel(old)> selfSay('Ol\á ' .. getCreatureName(cid) .. '!')
selfSay('TEXT')

NPC Channel(new)> selfSay('Hello ' .. getCreatureName(cid) .. '!', cid)
selfSay('TEXT', cid)
 
So, I have to change that in every single part of the npc script?, I mean in every part where the NPC is going to talk I have to change that?
 
Well, you can always try adding this to your global.lua:
Code:
function selfSay(text)
    return selfSay(text, cid)
end
 
So what and where do you need to add stuff
to make the NPC channel open up in blue text
when you talk with an NPC?

selfSay(text) sends the message through the default channel
selfSay(text, cid) sends the message through the NPC channel to the specific cid

So all you need to do is change your selfSay(text) lines to selfSay(text, cid). But I'm assuming you can't do this in the npc's xml file, so all your talking will have to be in the lua file. Correct me if I'm wrong because I haven't looked to see if it's possible, unless you use nodes?

Jo3
 
I dont see "Selfsay" anywhere on anything,
all says "NPCHandler:Say"

I think that you can add something to the NPC.lua?
in the lib folder?
 
NPC.xml
PHP:
<?xml version="1.0"?>
       
       <npc name="Captain Ab'Dendriel" script="data/npc/scripts/boat_ab_dendriel.lua" speed="40" access="3" floorchange="0" autowalk="0">
       	<health now="1000" max="1000"/>
      	<parameters>
      	<parameter key="message_greet" value="Hello,  |PLAYERNAME|. Welcome to my ship!" />		
      	</parameters>
       	<look type="129" head="116" body="114" legs="89" feet="95" corpse="1313"/>
       </npc>

SCRIPT.lua
PHP:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
        
        
        
        -- OTServ event handling functions start
        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
        -- OTServ event handling functions end
        
        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
        
        local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Carlin for free?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=32387, y=31820, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})

        local travelNode = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Thais for free?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=32310, y=32210, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
        local travelNode = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Edron for free'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=33173, y=31764, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
        local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Venore for free?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=32952, y=32022, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
        
        keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to Carlin, Edron, Thais and Venore.'})
        keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I only can offer you my services to Carlin, Edron, Thais and Venore.'})
        -- Makes sure the npc reacts when you say hi, bye etc.
        npcHandler:addModule(FocusModule:new())
 
Try with this, i dont know if it work but u can try :p
PHP:
<?xml version="1.0"?>
       
       <npc name="Captain Ab'Dendriel" script="data/npc/scripts/boat_ab_dendriel.lua" speed="40" access="3" floorchange="0" autowalk="0">
           <health now="1000" max="1000"/>
           <look type="129" head="116" body="114" legs="89" feet="95" corpse="1313"/>
       </npc>
PHP:
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end
 
---
 
 
function onCreatureAppear(cid)
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end
 
function onCreatureSay(cid, type, msg)
	if((msg == "hi") and not (isFocused(cid))) then
		addFocus(cid)
		selfSay("Hello, ".. getCreatureName(cid) .." Welcome to my ship!", cid)

	elseif((isFocused(cid)) and (msg == "carlin")) then
				selfSay("Do you want travel to carlin?", cid)
				talk_state = 1
			
	elseif((isFocused(cid)) and (msg == "yes")) and talk_state == 1 then
			carlin = {x=111, y=111, z=11} 
			if getPlayerItemCount(cid,2160) >= 1 then
					if doPlayerRemoveItem(cid,2160,1) == 1 then
						doTeleportThing(cid,calin)
						selfSay("Here we go.", cid)
					end

			else
				selfSay("You have not enough money!", cid)
			end



	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("Goodbye!", cid, TRUE)
		closeShopWindow(cid)
		removeFocus(cid)
	end
end
 
function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
	end
end
 
function onPlayerEndTrade(cid)
	selfSay("It was a pleasure doing business with you.", cid)
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				closeShopWindow(focus)
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end

Say me what happens :p

Cya
 
The NPC answers me in NPC Chat:

Default Chat:
21:38 Gm Cocoroto [1136]: hi

NPC Chat:
21:38 Captain Ab'Dendriel: Hello, Gm Cocoroto Welcome to my ship!
21:38 Gm Cocoroto [1136]: carlin
21:38 Captain Ab'Dendriel: Do you want travel to carlin?
21:38 Gm Cocoroto [1136]: yes

The problem is that..., the NPC doesnt take me to Carlin. He doesnt answer me after the: "21:38 Gm Cocoroto [1136]: yes".

Hope you can fix it, and thank you btw. :)

PS I changed the sqm where Im supposed to get teleported at the Carlin Boat.
 
Back
Top