robbydeath
Well-Known Member
Hello, I recently started working on my server for fun from so many years ago
I know this is probably a very simple fix but I can't figure it out
He will not focus he only responds to Hi and keeps walking
I was editing from several different npc trying to piece this one together
Thanks a lot in advance
I know this is probably a very simple fix but I can't figure it out
He will not focus he only responds to Hi and keeps walking
I was editing from several different npc trying to piece this one together
Thanks a lot in advance
Code:
focus = 0
talk_start = 0
target = 0
following = false
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)
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. creatureGetName(cid) .. '! I need 100 worms for my famous worm soup. Can you help me? Find them in the hole east of here inside the
bank.')
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, 'worms') then
doPlayerRemoveItem(cid,3976,100)
doPlayerAddItem(cid,2525,1)
elseif msgcontains(msg, 'worm') then
doPlayerRemoveItem(cid,3976,100)
doPlayerAddItem(cid,2525,1)
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('You saved the day! Thank you, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 500 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end