• 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!

Npc

Saj

Remember my name
Joined
Feb 26, 2008
Messages
2,127
Reaction score
6
Hey guys! This is the npc I use, I can't buy wands or rods or singel runes, could anyone help me?
Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end

function buyContainer(cid, container, itemid, count, money)
   if doPlayerRemoveMoney(cid, money) == 1 then
      bp = doPlayerAddItem(cid, container, 1)
      x = 0
      
      while x < 20 do
         doAddContainerItem(bp, itemid, count)
         x = x + 1
      end
      
      selfSay('Aqui tienes.')
   else
      selfSay('Lastima, no te alcanza.')
   end
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 ' .. getCreatureName(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, ' .. getCreatureName(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 (100gps), uhs (150gps), gfbs (100gps), explosions (225gps), sds (300gps), blank runes (10gps).')
      elseif msgcontains(msg, 'wands') then
         selfSay('I sell wand of inferno(lightning) (5k), plague (1k), cosmic energy (3k), vortex (Free) and dragonbreath (100gp).')
      elseif msgcontains(msg, 'rods') then
         selfSay('I sell quagmire (3k), snakebite (Free), tempest(hailstorm) (5k), volcanic (1k) and moonlight rod (100gp).')

      elseif msgcontains(msg, 'inferno') then
         buy(cid,2187,getCount(msg),5000)
      elseif msgcontains(msg, 'lightning') then
         buy(cid,2187,getCount(msg),5000)
      elseif msgcontains(msg, 'plague') then
         buy(cid,2188,getCount(msg),1000)
      elseif msgcontains(msg, 'cosmic energy') then
         buy(cid,2189,getCount(msg),3000)
      elseif msgcontains(msg, 'vortex') then
         buy(cid,2190,getCount(msg),500)
      elseif msgcontains(msg, 'dragonbreath') then
         buy(cid,2191,getCount(msg),100)

      elseif msgcontains(msg, 'quagmire') then
         buy(cid,2181,getCount(msg),3000)
      elseif msgcontains(msg, 'snakebite') then
         buy(cid,2182,getCount(msg),500)
      elseif msgcontains(msg, 'tempest') then
         buy(cid,2183,getCount(msg),5000)
      elseif msgcontains(msg, 'hailstorm') then
         buy(cid,2183,getCount(msg),5000)
      elseif msgcontains(msg, 'volcanic') then
         buy(cid,2185,getCount(msg),1000)
      elseif msgcontains(msg, 'moonlight') then
         buy(cid,2186,getCount(msg),100)

      elseif msgcontains(msg, 'bp sds') then
         buyContainer(cid,2003,2268,5,4000)
         
                elseif msgcontains(msg, 'bp hmms') then
         buyContainer(cid,2001,2311,15,200)         
               
                elseif msgcontains(msg, 'bp manafluids') then
print(buyContainer)
         buyContainer(cid,3940,2006,7,1000)             
               
                elseif msgcontains(msg, 'bp uhs') then
         buyContainer(cid,2002,2273,5,2000)      
       
                elseif msgcontains(msg, 'bp gfbs') then
         buyContainer(cid,2000,2304,6,1500)               
      
                elseif msgcontains(msg, 'bp explosions') then
         buyContainer(cid,2001,2313,6,3500)               
       
                elseif msgcontains(msg, 'bp blank') then
         buyContainer(cid,1988,2260,1,200)
   
      elseif msgcontains(msg, 'bp destroy fields') then
         buyContainer(cid,2003,2261,6,1000)     
      
      elseif msgcontains(msg, 'bp mana potions') then
         buyContainer(cid,1988,7620,1,1000)                 

      elseif msgcontains(msg, 'bp great mana potions') then
         buyContainer(cid,1988,7590,1,5000)   

      elseif msgcontains(msg, 'bp strong mana potions') then
         buyContainer(cid,1988,7589,1,2500)   

      elseif msgcontains(msg, 'bp health potions') then
         buyContainer(cid,1988,7618,1,1000)                 

      elseif msgcontains(msg, 'bp great health potions') then
         buyContainer(cid,1988,7591,1,5000)   

      elseif msgcontains(msg, 'bp strong health potions') then
         buyContainer(cid,1988,7588,1,2500)   
               

      elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
         selfSay('Good bye, ' .. getCreatureName(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
 
Try this one:

data\npc\Runes.xml:
Code:
     Code:
     <npc name="Mike" script="data/npc/scripts/runes.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="130" head="39" body="122" legs="125" feet="57" corpse="2212"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to buy any spell runes?" />
        <parameter key="message_needmoremoney" value="You do not have enough money." />
        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!" />
    </parameters>
</npc>
data\npc\scripts\runes.lua:
Code:
     local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
 
 
-- OTServ event handling functions start
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                         npcHandler:onThink() end
-- OTServ event handling functions end
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addBuyableItem({'light wand', 'lightwand'},         2163, 500,         'magic light wand')
shopModule:addBuyableItem({'mana fluid', 'manafluid'},         2006, 100,     7,     'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'},         2006, 80,     10,    'life fluid')
shopModule:addBuyableItem({'heavy magic missile', 'hmm'},     2311, 125,     10,    'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball', 'gfb'},             2304, 180,     4,     'great fireball rune')
shopModule:addBuyableItem({'explo', 'xpl'},                     2313, 250,     6,     'explosion rune')
shopModule:addBuyableItem({'ultimate healing', 'uh'},         2273, 175,     2,     'ultimate healing rune')
shopModule:addBuyableItem({'sudden death', 'sd'},             2268, 325,     2,     'sudden death rune')
shopModule:addBuyableItem({'blank', 'rune'},                     2260, 10,         'blank rune')
 
 
npcHandler:addModule(FocusModule:new())
 
Try this one:

data\npc\Runes.xml:
Code:
     Code:
     <npc name="Mike" script="data/npc/scripts/runes.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="130" head="39" body="122" legs="125" feet="57" corpse="2212"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to buy any spell runes?" />
        <parameter key="message_needmoremoney" value="You do not have enough money." />
        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!" />
    </parameters>
</npc>
data\npc\scripts\runes.lua:
Code:
     local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
 
 
-- OTServ event handling functions start
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                         npcHandler:onThink() end
-- OTServ event handling functions end
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addBuyableItem({'light wand', 'lightwand'},         2163, 500,         'magic light wand')
shopModule:addBuyableItem({'mana fluid', 'manafluid'},         2006, 100,     7,     'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'},         2006, 80,     10,    'life fluid')
shopModule:addBuyableItem({'heavy magic missile', 'hmm'},     2311, 125,     10,    'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball', 'gfb'},             2304, 180,     4,     'great fireball rune')
shopModule:addBuyableItem({'explo', 'xpl'},                     2313, 250,     6,     'explosion rune')
shopModule:addBuyableItem({'ultimate healing', 'uh'},         2273, 175,     2,     'ultimate healing rune')
shopModule:addBuyableItem({'sudden death', 'sd'},             2268, 325,     2,     'sudden death rune')
shopModule:addBuyableItem({'blank', 'rune'},                     2260, 10,         'blank rune')
 
 
npcHandler:addModule(FocusModule:new())

well that one might work but, it doesn't sell bp of sd or wands nor rods..
 
Back
Top