focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
if language == 1 then
selfSay('Good bye then.')
elseif language == 2 then
selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
end
focus = 0
talk_start = 0
language = 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 ' .. getCreatureName(cid) .. '!', cid)
focus = cid
talk_start = os.clock()
language = 1
elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Ol\á ' .. getCreatureName(cid) .. '!', cid)
focus = cid
talk_start = os.clock()
language = 2
end
if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
end
if focus == cid then
talk_start = os.clock()
end
if msgcontains(msg, 'help') and language == 1 and getDistanceToCreature(cid) < 4 then
selfSay('I don\'t help.', cid)
elseif msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
focus = 0
talk_start = 0
language = 0
end
if msgcontains(msg, 'ajuda') and language == 2 and getDistanceToCreature(cid) < 4 then
selfSay('Desculpa mas eu n\ão irei lhe ajudar.', cid)
elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
focus = 0
talk_start = 0
language = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
if language == 1 then
selfSay('Next Please...')
elseif language == 2 then
selfSay('O pr\óximo por favor.')
end
end
language = 0
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
if language == 1 then
selfSay('Good bye then.')
elseif language == 2 then
selfSay('Tchau.')
end
language = 0
focus = 0
end
end
end