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

How to change npc talk channel

kret

K R E T O W N A G E
Joined
Apr 4, 2008
Messages
949
Reaction score
6
Location
PяOLAND
hello


i have a npc Sebastian and all npcs on my ots talks on NPCs Channel but this npc talk on default. How i can change this ?

There is a script

Code:
local focus = 0
local talk_start = 0

local nargor = {x=31987, y=32882, z=6, price = 60}
local libertybay = {x=32285, y=32892, z=6, price = 60}

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
	if focus == cid then
		selfSay('Hmm...')
		focus = 0
		talk_start = 0
	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function sail(cid, destination)
	if doPlayerRemoveMoney(cid, destination.price) == TRUE then
		doTeleportThing(cid, destination)
		focus = 0
		talk_start = 0
	else
		selfSay(getCreatureName(cid).. '... You don\'t have enough money.')
	end 
end

function onCreatureSay(cid, type, msg)
	msg = string.lower(msg)

	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Hello, Sir '.. getCreatureName(cid))
		focus = cid
		talk_start = os.clock()
		talk_state = 0

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay(getCreatureName(cid) ..', please wait for your turn.')

	elseif focus == cid then
		talk_start = os.clock()
		
		if msgcontains(msg, 'liberty bay') then
			selfSay('Do you want to sail to Liberty Bay for 60 gold coins?')		
			talk_state = 1
		elseif msgcontains(msg, 'nargor') and getPlayerStorageValue(cid, 527983) == 7 then
			selfSay('Do you want to sail to Nargor for 60 gold coins?')		
			talk_state = 2
		elseif msgcontains(msg, 'yes') then
			if talk_state == 1 then
				sail(cid, libertybay)
			elseif talk_state == 2 then
				if getPlayerStorageValue(cid, 527983) == 7 then sail(cid, nargor) end
			end
		elseif msgcontains(msg, 'no') then
			selfSay('Then stay here!')
			talk_state = 0
		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('See you.')
			focus = 0
			talk_start = 0
		end
	
	end
end

function onCreatureChangeOutfit(creature)

end


function onThink()
	if focus > 0 then
		if (os.clock() - talk_start) > 30 then
			selfSay('Bye.')
			focus = 0
		elseif getDistanceToCreature(focus) > 3 then
			selfSay('Bye.')
			focus = 0
		end
	end
end
 
Last edited by a moderator:
If your server got the new system already uve just to change that in the xml of the npc talkstat or something
if ou dont have it download another TFS or just update the npc system
 
Im using TFS 0.2 patch 20


THis is XML of NPC Sebastian
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Sebastian" script="data/npc/scripts/sebastian.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="151" head="95" body="53" legs="109" feet="115" addons="3"/>
</npc>
 
Error ;/
[19/12/2008 23:10:25] Lua Script Error: [Npc interface]
[19/12/2008 23:10:25] data/npc/scripts/sebastian.lua:onCreatureSay

[19/12/2008 23:10:25] data/npc/scripts/sebastian.lua:49: attempt to index global 'npcHandler' (a nil value)
[19/12/2008 23:10:25] stack traceback:
[19/12/2008 23:10:25] data/npc/scripts/sebastian.lua:49: in function <data/npc/scripts/sebastian.lua:45>
 
Back
Top