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 wands, rods, runes, bp rune, potions, bp potion.')
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 hmms (1000gps), uhs (3000gps), gfbs (1500gps), explosions (3500gps), sds (5000gps), manarune (8000gps), blank runes (10gps).')
elseif msgcontains(msg, 'wands') then
selfSay('I sell wand of inferno (15k), decay (5k), cosmic energy (10k), vortex (100gp) and dragonbreath (1000gp).')
elseif msgcontains(msg, 'rods') then
selfSay('I sell terra (10k), snakebite (100gp), hailstorm (15k), necrotic (5k) and moonlight rod (1000gp).')
elseif msgcontains(msg, 'bp rune') then
selfSay('I sell bp sds (80k), bp uhs (60k), bp hmms (20k), bp gfbs (30k), bp explosions (70k), bp magic walls (80k), bp blank (20gp), bp fire bombs (60k), bp destroy fields (10k).')
elseif msgcontains(msg, 'potions') then
selfSay('I mana potion (mp 50gp), strong mana potion (smp 100gp), great mana potion (gmp 200gp), health potion (hp 60gp), strong health potion (shp 110gp), great health potion (ghp 210gp).')
elseif msgcontains(msg, 'bp potion') then
selfSay('I sell bp mp (1k), bp smp (2k), bp gmp (4k), bp hp (1,2k), bp shp (2,2k), bp ghp (4,2k).')
elseif msgcontains(msg, 'bp mp') then
buyContainer(cid,2001,7620,1,1000)
elseif msgcontains(msg, 'bp smp') then
buyContainer(cid,2001,7589,1,2000)
elseif msgcontains(msg, 'bp gmp') then
buyContainer(cid,2001,7590,1,4000)
elseif msgcontains(msg, 'bp hp') then
buyContainer(cid,2000,7618,1,1200)
elseif msgcontains(msg, 'bp shp') then
buyContainer(cid,2000,7588,1,2200)
elseif msgcontains(msg, 'bp ghp') then
buyContainer(cid,2000,7591,1,4200)
elseif msgcontains(msg, 'hp') then
buy(cid,7618,getCount(msg),60)
elseif msgcontains(msg, 'shp') then
buy(cid,7588,getCount(msg),110)
elseif msgcontains(msg, 'ghp') then
buy(cid,7591,getCount(msg),210)
elseif msgcontains(msg, 'mp') then
buy(cid,7620,getCount(msg),50)
elseif msgcontains(msg, 'smp') then
buy(cid,7589,getCount(msg),100)
elseif msgcontains(msg, 'gmp') then
buy(cid,7590,getCount(msg),200)
elseif msgcontains(msg, 'inferno') then
buy(cid,2187,getCount(msg),15000)
elseif msgcontains(msg, 'decay') then
buy(cid,2188,getCount(msg),5000)
elseif msgcontains(msg, 'cosmic energy') then
buy(cid,2189,getCount(msg),10000)
elseif msgcontains(msg, 'vortex') then
buy(cid,2190,getCount(msg),100)
elseif msgcontains(msg, 'dragonbreath') then
buy(cid,2191,getCount(msg),1000)
elseif msgcontains(msg, 'terra') then
buy(cid,2181,getCount(msg),10000)
elseif msgcontains(msg, 'snakebite') then
buy(cid,2182,getCount(msg),100)
elseif msgcontains(msg, 'hailstorm') then
buy(cid,2183,getCount(msg),15000)
elseif msgcontains(msg, 'necrotic') then
buy(cid,2185,getCount(msg),5000)
elseif msgcontains(msg, 'moonlight') then
buy(cid,2186,getCount(msg),1000)
elseif msgcontains(msg, 'hmm') then
buy(cid,2311,getCount(msg),1000)
elseif msgcontains(msg, 'gfb') then
buy(cid,2304,getCount(msg),1500)
elseif msgcontains(msg, 'explo') then
buy(cid,2313,getCount(msg),3500)
elseif msgcontains(msg, 'uh') then
buy(cid,2273,getCount(msg),3000)
elseif msgcontains(msg, 'sd') then
buy(cid,2268,getCount(msg),5000)
elseif msgcontains(msg, 'blank') then
buy(cid,2260,getCount(msg),1)
elseif msgcontains(msg, 'manarune') then
buy(cid,2270,getCount(msg),8000)
elseif msgcontains(msg, 'bp sds') then
buyContainer(cid,2003,2268,100,80000)
elseif msgcontains(msg, 'bp hmms') then
buyContainer(cid,2001,2311,100,20000)
elseif msgcontains(msg, 'bp uhs') then
buyContainer(cid,2002,2273,100,60000)
elseif msgcontains(msg, 'bp gfbs') then
buyContainer(cid,2000,2304,100,30000)
elseif msgcontains(msg, 'bp explosions') then
buyContainer(cid,2001,2313,100,70000)
elseif msgcontains(msg, 'bp blank') then
buyContainer(cid,1988,2260,1,20)
elseif msgcontains(msg, 'bp magic walls') then
buyContainer(cid,1999,2293,100,80000)
elseif msgcontains(msg, 'bp fire bombs') then
buyContainer(cid,2000,2305,100,60000)
elseif msgcontains(msg, 'bp destroy fields') then
buyContainer(cid,2003,2261,100,10000)
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) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end