• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Help with npc selling runes with charges

celohere

Advanced OT User
Joined
Nov 27, 2007
Messages
270
Solutions
21
Reaction score
153
I would like the script npc who sells runes of any charge.
EX: hi 46 sd yes
hi 99 uh yes ...

I'm using cryingdamson6pl1 someone could help?
 
PHP:
-- Script de venda de runes, wands e rods
-- Bugs de compra de 0 runas arrumado By Kyngpin

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 and rods e Axe Fodao.')
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 (10gps cada), uhs (30gps cada), light,strong,great manarunes (120gps each), gfbs (20gps each), explosions (30gps each), sds (40gps each) and blank runes (5gps each).')
elseif msgcontains(msg, 'wands') then
selfSay('I sell wand of inferno (15k), plague (5k), cosmic energy (10k), vortex (free) and dragonbreath (1k).')
elseif msgcontains(msg, 'rods') then
selfSay('I sell quagmire (10k), snakebite (free), tempest (15k), volcanic (5k) and moonlight rod (1k).')

-- inicio da venda de wands =)

elseif msgcontains(msg, 'woi') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 wand of inferno? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2187,count,15000)
   end

elseif msgcontains(msg, 'plague') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 wand of plague? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2188,count,5000)
   end

elseif msgcontains(msg, 'cosmic energy') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 wand of cosmic energy? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2189,count,10000)
   end

elseif msgcontains(msg, 'vortex') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 wand of vortex? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2190,count,0)
   end

elseif msgcontains(msg, 'dragonbreath') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Wand of Dragonbreath? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2191,count,1000)
   end

elseif msgcontains(msg, 'Axe Fodao') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Axe Fodao? LOL?')
      talk_start = os.clock()
   else
      buy(cid,3962,count,5000000)
   end
-- fim da venda de wands =)
-- inicio da venda de rods =)

elseif msgcontains(msg, 'quagmire') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Quagmire Rod? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2181,count,10000)
   end

elseif msgcontains(msg, 'snakebite') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Snakebite Rod? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2182,count,0)
   end

elseif msgcontains(msg, 'tempest') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Tempest Rod? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2183,count,15000)
   end

elseif msgcontains(msg, 'volcanic') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Volcanic Rod? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2185,count,5000)
   end

elseif msgcontains(msg, 'moonlight') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Moonlight Rod? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2186,count,1000)
   end

-- fim da venda de rods =)
-- inicio da venda de runas =)

elseif msgcontains(msg, 'hmm') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Hmm? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2311,count,10)
   end

elseif msgcontains(msg, 'magic wall') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Hmm? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2293,count,20)
   end

elseif msgcontains(msg, 'light manarune') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Hmm? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2294,count,20)
   end

elseif msgcontains(msg, 'strong manarune') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Hmm? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2307,count,25)
   end

elseif msgcontains(msg, 'great manarune') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 Hmm? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2264,count,30)
   end

elseif msgcontains(msg, 'Shinoda ots eh o melhor') then
   count = getCount(msg)
   if count == 0 then
      selfSay('Im Not Sell 0 Mana Rune!, Continue buying :)')
      talk_start = os.clock()
   else
      buy(cid,2281,count, 20000)
   end   

elseif msgcontains(msg, 'uh') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 UH? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2273,count,15)
   end

elseif msgcontains(msg, 'gfb') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 GFB? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2304,count,20)
   end

elseif msgcontains(msg, 'explosion') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 EXPLO? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2313,count,12)
   end

elseif msgcontains(msg, 'sd') then
   count = getCount(msg)
   if count == 0 then
      selfSay('0 SD? LOL?')
      talk_start = os.clock()
   else
      buy(cid,2268,count,15)
   end

elseif msgcontains(msg, 'bSDlank') then
   count = getCount(msg)
   if count == 0 then
      selfSay('Im Not Sell 0 Blank Rune!, Continue buying :)')
      talk_start = os.clock()
   else
      buy(cid,2260,count,5)
   end

-- fim da venda de runas =)

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

There are also 3 manarunes added. But if u dont use that runes there should be no problem :)
 
does not work here's the error in console

[21/04/2010 10:28:04] [Error - Npc interface]
[21/04/2010 10:28:04] data/npc/scripts/runes.lua:eek:nCreatureSay
[21/04/2010 10:28:04] Description:
[21/04/2010 10:28:04] data/npc/scripts/runes.lua:43: attempt to call global 'creatureGetName' (a nil value)
[21/04/2010 10:28:04] stack traceback:
[21/04/2010 10:28:04] data/npc/scripts/runes.lua:43: in function <data/npc/scripts/runes.lua:39>
 
now i have that error:
21/04/2010 11:04:35] [Error - Npc interface]
[21/04/2010 11:04:35] data/npc/scripts/runes.lua:eek:nCreatureSay
[21/04/2010 11:04:35] Description:
[21/04/2010 11:04:35] data/npc/scripts/runes.lua:221: attempt to call global 'getCount' (a nil value)
[21/04/2010 11:04:35] stack traceback:
[21/04/2010 11:04:35] data/npc/scripts/runes.lua:221: in function <data/npc/scripts/runes.lua:39>
 
Back
Top