• 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 Adding cost to NPC script

Elvarion

Member
Joined
Apr 14, 2010
Messages
99
Reaction score
13
So ive got a script that works like the Djinns where you trade items for other items.

Im gonna extend this script and make it into a Blacksmith.
He will give you items if you bring him certain items + a payment (in gold)

Its the cost im having some trouble adding..


Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

-- Keywords
npcHandler:setMessage(MESSAGE_GREET, "[Blacksmith}, |PLAYERNAME|?")

keywordHandler:addKeyword({'blacksmith'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = '{weapons}{armor}?'})

keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = '{Magic Sword}, {Great Axe} ETC ETC'})
keywordHandler:addKeyword({'armor'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = '{Dragon Scale Mail}, {Knight Armor} ETC ETC'})


function ChickenWing(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
    if getPlayerItemCount(cid,2195) >= 1 then
        if doPlayerRemoveItem(cid,2195,1) then
            npcHandler:say('Here is your {Enchanted Chicken Wing}. Thanks for the {Boots of Haste}.', cid)
            doPlayerAddItem(cid,5891,1)
        end
        else
            npcHandler:say('Sorry, You dont seem to have any {Boots of Haste}', cid)
        end
        end
      
function FightingSpirit(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
    if getPlayerItemCount(cid,2498) >= 2 then
        if doPlayerRemoveItem(cid,2498,1) then
            npcHandler:say('A {Royal Helmet}! Great. Here, take this fighting spirit, I don\'t need it anyway.', cid)
            doPlayerAddItem(cid,5884,1)
        end
        else
            npcHandler:say('Sorry, Your missing some items.', cid)
        end
        end

function MagicSulphur(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
    if getPlayerItemCount(cid,2392) >= 3 then
        if doPlayerRemoveItem(cid,2392,3) then
            npcHandler:say('Great, needed some more {Fire Swords}! Here is some {Magic Sulphur}.', cid)
            doPlayerAddItem(cid,5904,1)
        end
        else
            npcHandler:say('Sorry, you dont seem to have enough {Fire Sword}.', cid)
        end
        end

function WarriorsSweat(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
    if getPlayerItemCount(cid,2475) >= 4 then
        if doPlayerRemoveItem(cid,2475,3) then
            npcHandler:say('Here is your {Flask of Warrior\'s Sweat} for the {Warrior Helmets}.', cid)
            doPlayerAddItem(cid,5904,1)
        end
        else
            npcHandler:say('Sorry, Your missing some items.', cid)
        end
        end

function SoulOrb(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
    if getPlayerItemCount(cid,5944) >= 5 then
        if doPlayerRemoveItem(cid,5944,5) then
            npcHandler:say('Here you go. Ive reforged your {Soul Orbs} into some {Infernal Bolts}.', cid)
            doPlayerAddItem(cid,6529,15)
        end
        else
            npcHandler:say('Sorry, Your missing some items.', cid)
        end
        end
  
node1 = keywordHandler:addKeyword({'enchanted chicken wing'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you found a {Boots of haste} for me?'})
node1:addChildKeyword({'yes'}, ChickenWing, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node2 = keywordHandler:addKeyword({'fighting spirit'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you found a 2 {Royal Helmets} for me?'})
node2:addChildKeyword({'yes'}, FightingSpirit, {})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node3 = keywordHandler:addKeyword({'magic sulphur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you found 3 {fire swords} for me?'})
node3:addChildKeyword({'yes'}, MagicSulphur, {})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node4 = keywordHandler:addKeyword({'warrior\'s sweat'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you found a 4 {warrior helmets} for me?'})
node4:addChildKeyword({'yes'}, WarriorsSweat, {})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node5 = keywordHandler:addKeyword({'soul orb'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Want me to reforge five [Soul Orbs] into some {Infernal Bolts}?'})
node5:addChildKeyword({'yes'}, SoulOrb, {})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

npcHandler:addModule(FocusModule:new())
 
Back
Top