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)
local msg = string.lower(msg)
if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes, wands, rods, and whole bps with runes.')
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, 'runes') then
selfSay('I sell bp hmms (0.5k), bp uhs (2k), bp gfbs (2k), bp explosions (2.5k), bp sds (4k), bp manafluids (1k), bp lifefluids (2k), bp blank runes (200gps), remember to say (bp sds) bp sd!')
elseif msgcontains(msg, 'wands') then
selfSay('I sell wand of inferno (2k), plague (100gp), cosmic energy (500gp), and dragonbreath (1gp).')
elseif msgcontains(msg, 'rods') then
selfSay('I sell quagmire (500gp), snakebite (1gp), tempest (2k), volcanic (100gp) and moonlight rod (free).')
elseif msgcontains(msg, 'inferno') then
buy(cid,2187,getCount(msg),2000)
elseif msgcontains(msg, 'plague') then
buy(cid,2188,getCount(msg),100)
elseif msgcontains(msg, 'cosmic energy') then
buy(cid,2189,getCount(msg),500)
elseif msgcontains(msg, 'dragonbreath') then
buy(cid,2191,getCount(msg),1)
elseif msgcontains(msg, 'quagmire') then
buy(cid,2181,getCount(msg),500)
elseif msgcontains(msg, 'tempest') then
buy(cid,2183,getCount(msg),2000)
elseif msgcontains(msg, 'volcanic') then
buy(cid,2185,getCount(msg),500)
elseif msgcontains(msg, 'moonlight') then
buy(cid,2186,getCount(msg),1)
elseif msgcontains(msg, 'bp sds') then
buyContainer(cid,2003,2268,3,4000)
elseif msgcontains(msg, 'bp hmms') then
buyContainer(cid,2001,2311,15,500)
elseif msgcontains(msg, 'bp manafluids') then
buyContainer(cid,3940,2006,7,1000)
elseif msgcontains(msg, 'bp lifefluids') then
buyContainer(cid,2000,2006,10,2000)
elseif msgcontains(msg, 'bp uhs') then
buyContainer(cid,2002,2273,3,2000)
elseif msgcontains(msg, 'bp gfbs') then
buyContainer(cid,2000,2304,9,2000)
elseif msgcontains(msg, 'bp explosions') then
buyContainer(cid,2001,2313,9,2500)
elseif msgcontains(msg, 'bp blank') then
buyContainer(cid,1988,2260,1,200)
elseif msgcontains(msg, 'bp magic walls') then
buyContainer(cid,1999,2293,3,500)
elseif msgcontains(msg, 'bp fire bombs') then
buyContainer(cid,2000,2305,6,500)
elseif msgcontains(msg, 'bp destroy fields') then
buyContainer(cid,2003,2261,9,500)
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
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) > 4 then
selfSay('Good bye then.')
focus = 0
end
end
end