• 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 Freeze at 10 people talking with him.

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello.
I've little problem.
When like ~10 peoples talking to NPC, he going freeze - not responding and staying (not walking).

TFS 0.3.5pl1
Anyone can fix this problem ?
REPPP+++

Here's script:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  if focus == cid then
          selfSay('Good bye then.')
          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 onCreatureSay(cid, type, msg)
  msg = string.lower(msg)

  -- greeting phrase
if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 4 then
    selfSay('Welcome in my house! My name is Oracle, i can teleport you to main land!')
    focus = cid
  talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
    selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

elseif focus == cid then
  talk_start = os.clock()




   if msgcontains(msg, 'leave') then
        if getPlayerLevel(cid) >= 8 then
            selfSay('Are you sure?')
             talk_state = 459
        else
            selfSay('Sorry, you need level 8 to leave rookgaard.')
            talk_state = 0
        end


   elseif talk_state == 459 then

if msgcontains(msg, 'yes') then
if getPlayerLevel(cid) >= 8 then

goku = {x=725, y=505, z=6}
vegeta = {x=496, y=476, z=7}
trunk = {x=496, y=476, z=7}
brolly = {x=380, y=301, z=6}
bubu = {x=340, y=734, z=8}
freezer = {x=800, y=90, z=6}
cell = {x=674, y=216, z=8}
gohan = {x=725, y=505, z=6}
bardock = {x=380, y=301, z=6}
piccolo = {x=936, y=194, z=5}

    if getPlayerVocation(cid) == 1 then -- Goku
	doPlayerSetTown(cid,2)
	doTeleportThing(cid,goku)
        selfSay('See Ya !')


    elseif getPlayerVocation(cid) == 8 then -- Vegeta
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,vegeta)
        selfSay('See Ya')


    elseif getPlayerVocation(cid) == 19 then -- Trunk
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,trunk)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 27 then -- Brolly
    	doPlayerSetTown(cid,1)
	doTeleportThing(cid,brolly)
        selfSay('See Ya')
        
    elseif getPlayerVocation(cid) == 35 then -- Bubu
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,bubu)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 43 then -- Freezer
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,freezer)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 55 then -- Cell
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,cell)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 63 then -- Gohan
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,gohan)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 71 then -- Bardock
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,bardock)
        selfSay('See Ya')

    elseif getPlayerVocation(cid) == 79 then -- Piccolo
    	doPlayerSetTown(cid,2)
	doTeleportThing(cid,piccolo)
        selfSay('See Ya')


  elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
  selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
  focus = 0
  talk_start = 0
  end
end
end
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()

if (os.clock() - talk_start) > 30 then
    if focus > 0 then
    selfSay('Next Please...')
    end
    focus = 0
  end
  if focus ~= 0 then
  if getDistanceToCreature(focus) > 2 then
    selfSay('Good bye then.')
    focus = 0
  end
  end
end
 
?! ?!
that npc can only talk to 1 person at a time

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local t = {
-- [voc] = {town, teleportPos},
	 [1] = {2, {x=725, y=505, z=6}}, -- goku
	 [8] = {2, {x=496, y=476, z=7}}, -- vegeta
	[19] = {2, {x=496, y=476, z=7}}, -- trunk
	[27] = {1, {x=380, y=301, z=6}}, -- brolly
	[35] = {2, {x=340, y=734, z=8}}, -- bubu
	[43] = {2, {x=800, y=90, z=6}}, -- freezer
	[55] = {2, {x=674, y=216, z=8}}, -- cell
	[63] = {2, {x=725, y=505, z=6}}, -- gohan
	[71] = {2, {x=380, y=301, z=6}}, -- bardock
	[79] = {2, {x=936, y=194, z=5}} -- piccolo
}

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] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'leave') or msgcontains(msg, 'teleport') or msgcontains(msg, 'transport') then
		if getPlayerLevel(cid) >= 8 then
			selfSay('Are you sure?', cid)
			Topic[cid] = 1
		else
			selfSay('Sorry, you need level 8 to leave rookgaard.')
			Topic[cid] = 0
		end
	elseif Topic[cid] == 1 and msgcontains(msg, 'yes') then
		local v = t[getPlayerVocation(cid)]
		doPlayerSetTown(cid, v[1])
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, v[2])
		doSendMagicEffect(v[2], CONST_ME_TELEPORT)
		selfSay('See ya\'!')
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, "Welcome in my house, |PLAYERNAME|! My name is Oracle, I can {teleport} you to main land!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:

Similar threads

  • Question Question
Replies
0
Views
190
Back
Top