I'm getting a console error when someone dies or logout while talking with this npc
THE ERROR:
NPC.lua:
Can someone help me, please?
I want the NPC to stop talk with someone only when someone walk more then 30 sqm or logout/die.
THE ERROR:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/quest.lua:onThink
luaCreatureGetPos(). Creature not found
NPC.lua:
Code:
local focus = 0
local talk_start = 0
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 onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('...')
focus = 0
talk_start = 0
end
end
function onCreatureSay(cid, type, text)
local msg = string.lower(text)
if msgcontains(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. getCreatureName(cid) .. '! Voce quer ir para a quest?')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Desculpe, '..getCreatureName(cid).. '! Somente 1 por vez na quest, aguarde sua vez.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'yes') then
if pay(cid,0) then
travel(cid, 876, 60, 0)
selfSay('Que o poder saiyajin esteja com voce!')
else
selfSay('Sorry, you don\'t have enough money.')
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = os.clock()
end
end
end
function onThink()
if focus == 0 then return true end
if not isCreature(focus) then focus = 0 selfSay("Próximo por favor...") return true end
doNpcSetCreatureFocus(focus)
if not getDistanceToCreature(focus) or getDistanceToCreature(focus) > 30 then
selfSay('Próximo por favor...')
focus = 0
end
end
Can someone help me, please?
I want the NPC to stop talk with someone only when someone walk more then 30 sqm or logout/die.