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:
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