• 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 Buy more than one backpack of manas at the time.

Zt0ffe

New Member
Joined
Sep 26, 2008
Messages
341
Reaction score
4
Location
Sweden
Hello there!

Im using this code for my server, but is there any possible way you can change so you can buy more than 1 backpack at the time, instead of bp mfs you can say 2 bp mfs? :)

Using OTX based TFS eninge. Most of simple scripts works as on TFS.

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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
    npcHandler:say('Do you want to buy a backpack of blank runes for 200 gold coins?')
    talk_state = 1
 
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerMoney(cid) >= 200 then
                blue_bp = doPlayerAddItem(cid, 1999, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doAddContainerItem(blue_bp, 2260, 1)
                doPlayerRemoveMoney(cid, 200)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
    end
 

if msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
    npcHandler:say('Do you want to buy a backpack of mana fluids for 2000 gold coins?')
    talk_state = 6
 
        elseif msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerMoney(cid) >= 2000 then
                purple_bp = doPlayerAddItem(cid, 2001, 1)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doAddContainerItem(purple_bp, 2006, 7)
                doPlayerRemoveMoney(cid, 2000)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
    end 
 
        return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')


-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas

--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

  local function msgContainsNumber(msg)
     return tonumber(string.match(msg, '[0-9]')) ~= nil and tonumber(string.match(msg, '[0-9]')) or 0
   end


    if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
        npcHandler:say('How many backpack\'s of blank runes would you like to buy at 200 gold coins per backpack?')
        talk_state = 1
   
        if (msgContainsNumber(msg) > 0 ) and talk_state == 1 then
            if getPlayerMoney(cid) >= (200 * msgContainsNumber(msg)) then
                blue_bp = doPlayerAddItem(cid, 1999, 1)
                for i = 1, msgContainsNumber(msg) do
                    doAddContainerItem(blue_bp, 2260, 20)
                end
                doPlayerRemoveMoney(cid, 200 * msgContainsNumber(msg) )
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money, you need ' .. (200 * msgContainsNumber(msg)) .. 'gp to purchase ' .. msgContainsNumber(msg) .. ' backpacks.')
                talk_state = 0
            end
        end
    
    elseif msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
        npcHandler:say('How many backpack\'s of mana fluids would you like to buy at 2000 gold coins per backpack?')
        talk_state = 6
   
        if (msgContainsNumber(msg) > 0 ) and talk_state == 6 then
            if getPlayerMoney(cid) >= (2000 * msgContainsNumber(msg)) then
                purple_bp = doPlayerAddItem(cid, 2001, 1)
                for i = 1, msgContainsNumber(msg) do
                    doAddContainerItem(purple_bp, 2006, 20)
                end
                doPlayerRemoveMoney(cid, 2000 * msgContainsNumber(msg) )
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money, you need ' .. (2000 * msgContainsNumber(msg)) .. 'gp to purchase ' .. msgContainsNumber(msg) .. ' backpacks.')
                talk_state = 0
            end
        end
    end
    return true
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')


-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas

--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
    local c = split(msg, " ")
    local bp_count = 1
    if(type(c[1]) == "number") then
        bp_count = c[1]      
    end

    if(bp_count == 1) then
        npcHandler:say('Do you want to buy a backpack of blank runes for 200 gold coins?')
    else
        npcHandler:say('Do you want to buy  ' .. bp_count .. ' backpacks of blank runes for ' .. (200 * bp_count) .. ' gold coins?')
    end
    talk_state = 1
   
    if msgcontains(msg, 'yes') and talk_state == 1 then
        if getPlayerMoney(cid) >= 200 * bp_count then
            for b = 1, bp_count do
                blue_bp = doPlayerAddItem(cid, 1999, 1)
                for i = 1, 20 do
                    doAddContainerItem(blue_bp, 2260, 1)
                end
            end

            doPlayerRemoveMoney(cid, 200 * bp_count)
            npcHandler:say('Thank you for buying.')
            talk_state = 0
        else
            npcHandler:say('You don\'t have enough money.')
            talk_state = 0
        end
    end
   
    return true
end
   

if msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
    local c = split(msg, " ")
    local bp_count = 1
    if(type(c[1]) == "number") then
        bp_count = c[1]      
    end

    if(bp_count == 1) then
        npcHandler:say('Do you want to buy a backpack of mana fluids for 2000 gold coins?')
    else
        npcHandler:say('Do you want to buy ' .. bp_count .. ' backpacks of mana fluids for  ' .. (2000 * bp_count) .. ' gold coins?')
    end
    talk_state = 6
   
        if msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerMoney(cid) >= 2000 * bp_count then
                for b = 1, bp_count do
                    purple_bp = doPlayerAddItem(cid, 2001, 1)
                    for i = 1, 20 do
                        doAddContainerItem(purple_bp, 2006, 7)
                    end
                end
           
                doPlayerRemoveMoney(cid, 2000 * bp_count)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
        end  
       
    return true
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')


-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas 

--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

  local function msgContainsNumber(msg)
     return tonumber(string.match(msg, '[0-9]')) ~= nil and tonumber(string.match(msg, '[0-9]')) or 0
   end


    if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
        npcHandler:say('How many backpack\'s of blank runes would you like to buy at 200 gold coins per backpack?')
        talk_state = 1
  
        if (msgContainsNumber(msg) > 0 ) and talk_state == 1 then
            if getPlayerMoney(cid) >= (200 * msgContainsNumber(msg)) then
                blue_bp = doPlayerAddItem(cid, 1999, 1)
                for i = 1, msgContainsNumber(msg) do
                    doAddContainerItem(blue_bp, 2260, 20)
                end
                doPlayerRemoveMoney(cid, 200 * msgContainsNumber(msg) )
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money, you need ' .. (200 * msgContainsNumber(msg)) .. 'gp to purchase ' .. msgContainsNumber(msg) .. ' backpacks.')
                talk_state = 0
            end
        end
   
    elseif msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
        npcHandler:say('How many backpack\'s of mana fluids would you like to buy at 2000 gold coins per backpack?')
        talk_state = 6
  
        if (msgContainsNumber(msg) > 0 ) and talk_state == 6 then
            if getPlayerMoney(cid) >= (2000 * msgContainsNumber(msg)) then
                purple_bp = doPlayerAddItem(cid, 2001, 1)
                for i = 1, msgContainsNumber(msg) do
                    doAddContainerItem(purple_bp, 2006, 20)
                end
                doPlayerRemoveMoney(cid, 2000 * msgContainsNumber(msg) )
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money, you need ' .. (2000 * msgContainsNumber(msg)) .. 'gp to purchase ' .. msgContainsNumber(msg) .. ' backpacks.')
                talk_state = 0
            end
        end
    end
    return true
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')


-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas

--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

With this code for example:
buy 5 bp mfs, I get 1 purple backpack, 5 and 5 vials of unknown. :p

Now, this is untested as F and i wrote it during a swedish lesson in school but give it a shot
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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
    local c = split(msg, " ")
    local bp_count = 1
    if(type(c[1]) == "number") then
        bp_count = c[1]      
    end
if(bp_count == 1) then
    npcHandler:say('Do you want to buy a backpack of blank runes for 200 gold coins?')
else
    npcHandler:say('Do you want to buy  ' .. bp_count .. ' backpacks of blank runes for ' .. (200 * bp_count) .. ' gold coins?')
end
    talk_state = 1
  
       if msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerMoney(cid) >= 200 * bp_count then
        for b = 1, bp_count do
                    blue_bp = doPlayerAddItem(cid, 1999, 1)
            for i = 1, 20 do
                        doAddContainerItem(blue_bp, 2260, 1)
            end
        end
                doPlayerRemoveMoney(cid, 200 * bp_count)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
    end
  

if msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
    local c = split(msg, " ")
    local bp_count = 1
    if(type(c[1]) == "number") then
        bp_count = c[1]      
    end
if(bp_count == 1) then
    npcHandler:say('Do you want to buy a backpack of mana fluids for 2000 gold coins?')
else
    npcHandler:say('Do you want to buy ' .. bp_count .. ' backpacks of mana fluids for  ' .. (2000 * bp_count) .. ' gold coins?')
end
    talk_state = 6
  
        if msgcontains(msg, 'yes') and talk_state == 6 then
            if getPlayerMoney(cid) >= 2000 * bp_count then
        for b = 1, bp_count do
                     purple_bp = doPlayerAddItem(cid, 2001, 1)
            for i = 1, 20 do
                          doAddContainerItem(purple_bp, 2006, 7)
            end
        end
                doPlayerRemoveMoney(cid, 2000 * bp_count)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
    end 
  
        return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')


-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas

--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

With your code I got this error in console (tried add another end):
Code:
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
 
Last edited by a moderator:
With your code I got this error in console (tried add another end):
Code:
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'

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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    if msgcontains(msg, 'bp blanks') or msgcontains(msg, 'bp of blanks') or msgcontains(msg, 'bp blank') then
        local c = split(msg, " ")
        local bp_count = 1
        if(type(c[1]) == "number") then
            bp_count = c[1]      
        end

        if(bp_count == 1) then
            npcHandler:say('Do you want to buy a backpack of blank runes for 200 gold coins?')
        else
            npcHandler:say('Do you want to buy  ' .. bp_count .. ' backpacks of blank runes for ' .. (200 * bp_count) .. ' gold coins?')
        end

        talk_state = 1

        if msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerMoney(cid) >= 200 * bp_count then
                for b = 1, bp_count do
                    blue_bp = doPlayerAddItem(cid, 1999, 1)
                    for i = 1, 20 do
                        doAddContainerItem(blue_bp, 2260, 1)
                    end
                end
                doPlayerRemoveMoney(cid, 200 * bp_count)
                npcHandler:say('Thank you for buying.')
                talk_state = 0
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
        end

        if msgcontains(msg, 'bp mf') or msgcontains(msg, 'bp manafluid') or msgcontains(msg, 'bp mana fluid') then
            local c = split(msg, " ")
            local bp_count = 1
            if(type(c[1]) == "number") then
                bp_count = c[1]      
            end

            if(bp_count == 1) then
                npcHandler:say('Do you want to buy a backpack of mana fluids for 2000 gold coins?')
            else
                npcHandler:say('Do you want to buy ' .. bp_count .. ' backpacks of mana fluids for  ' .. (2000 * bp_count) .. ' gold coins?')
            end
            talk_state = 6

            if msgcontains(msg, 'yes') and talk_state == 6 then
                if getPlayerMoney(cid) >= 2000 * bp_count then
                    for b = 1, bp_count do
                        purple_bp = doPlayerAddItem(cid, 2001, 1)
                        for i = 1, 20 do
                            doAddContainerItem(purple_bp, 2006, 7)
                        end
                    end
                    doPlayerRemoveMoney(cid, 2000 * bp_count)
                    npcHandler:say('Thank you for buying.')
                    talk_state = 0
                else
                    npcHandler:say('You don\'t have enough money.')
                    talk_state = 0
                end
            end 
        end
    end

    return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')
-- Spell Book
shopModule:addBuyableItem({'spellbook'}, 2175, 150,    'spellbook')
-- Fluids
shopModule:addBuyableItem({'life fluid','lifefluid'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid'},2006,55,7,'mana fluid')

-- Runas
--shopModule:addBuyableItem({'intense healing rune', 'ih'}, 2265, 95, 1, 'intense healing rune')
--shopModule:addBuyableItem({'ultimate healing rune', 'uh'}, 2273, 125, 1, 'ultimate healing rune')
--shopModule:addBuyableItem({'magic wall rune'}, 2293, 200, 3, 'magic wall rune')
--shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')
--shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 10, 'light magic missile rune')
--shopModule:addBuyableItem({'heavy magic missile rune', 'hmm'}, 2311, 50, 5, 'heavy magic missile rune')
--shopModule:addBuyableItem({'great fireball rune', 'gfb'}, 2304, 100, 4, 'great fireball rune')
--shopModule:addBuyableItem({'explosion rune', 'explosion'}, 2313, 150, 3, 'explosion rune')
--shopModule:addBuyableItem({'sudden death rune', 'sd'}, 2268, 225, 1, 'sudden death rune')
--shopModule:addBuyableItem({'death arrow rune'}, 2263, 300, 3, 'death arrow rune')
--shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')
--shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')
--shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')
--shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3, 'desintegreate rune')
--shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
With your code I got this error in console (tried add another end):
Code:
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:117: 'end' expected (to close 'function' at line 12) near '<eof>'
Edited my code, try it again
 
Edited my code, try it again

New Error:
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:123: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:123: 'end' expected (to close 'function' at line 12) near '<eof>'
[Error - LuaInterface::loadFile] data/npc/scripts/runes.lua:123: 'end' expected (to close 'function' at line 12) near '<eof>'
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/runes.lua
data/npc/scripts/runes.lua:123: 'end' expected (to close 'function' at line 12) near '<eof>'

- bumpish -
 
Last edited by a moderator:
Back
Top Bottom