Felipe93
Ghost Member
Lua:Lua Script Error: [Npc interface] data/npc/scripts/Xodet.lua:onCreatureSay data/npc/scripts/lib/npcsystem/npchandler.lua:642: table index is nil stack traceback: [C]: in function '__newindex' data/npc/scripts/lib/npcsystem/npchandler.lua:642: in function 'say' data/npc/scripts/Xodet.lua:78: in function 'callback' data/npc/scripts/lib/npcsystem/npchandler.lua:420: in function 'onCreatureSay' data/npc/scripts/Xodet.lua:12: in function <data/npc/scripts/Xodet.lua:12>
the npc work but it has problem when i want to buy bp of mf and i don't know with what word should i replace the code
Code:
if msgcontains(msg, 'bp of mf') or msgcontains(msg, 'bp of manafluid') or msgcontains(msg, 'bp mf') then
npcHandler:say('Do you want to buy a backpack of mana fluid for 2000 gold coins?')
talk_state = 6
elseif msgcontains(msg, 'yes') and talk_state == 6 then
if getPlayerMoney(cid) >= 2000 then
brown_bp = doPlayerAddItem(cid, 2001, 1)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_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
Code:
npcHandler:say('Do you want to buy a backpack of mana fluid for 2000 gold coins?')
Code:
dofile('data/npc/scripts/lib/greeting.lua')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions
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
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'life'}, 2006, 60, 10, 'life fluid')
shopModule:addBuyableItem({'mana'}, 2006, 100, 7, 'mana fluid')
shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'blank rune'}, 2260, 10, 'blank rune')
function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
if not npcHandler:isFocused(cid) then
return false
end
if msgcontains(msg, 'vial') or msgcontains(msg, 'deposit') or msgcontains(msg, 'flask') then
npcHandler:say("I will pay you 5 gold for every empty vial. Ok?", 1)
talk_state = 857
elseif talk_state == 857 and msgcontains(msg, 'yes') then
if sellPlayerEmptyVials(cid) == true then
npcHandler:say("Here's your money!", 1)
talk_state = 0
else
npcHandler:say("You don't have any empty vials!", 1)
talk_state = 0
end
end
if msgcontains(msg, 'bp of lf') or msgcontains(msg, 'bp of life fluid') or msgcontains(msg, 'bp lf') then
npcHandler:say('Do you want to buy a backpack of life fluid for 1200 gold coins?')
talk_state = 5
elseif msgcontains(msg, 'yes') and talk_state == 5 then
if getPlayerMoney(cid) >= 1200 then
purple2_bp = doPlayerAddItem(cid, 2000, 1)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doAddContainerItem(purple2_bp, 2006, 10)
doPlayerRemoveMoney(cid, 1200)
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 of mf') or msgcontains(msg, 'bp of manafluid') or msgcontains(msg, 'bp mf') then
npcHandler:say('Do you want to buy a backpack of mana fluid for 2000 gold coins?')
talk_state = 6
elseif msgcontains(msg, 'yes') and talk_state == 6 then
if getPlayerMoney(cid) >= 2000 then
brown_bp = doPlayerAddItem(cid, 2001, 1)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_bp, 2006, 7)
doAddContainerItem(brown_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
if msgcontains(msg, 'bp of br') or msgcontains(msg, 'bp of blank rune') or msgcontains(msg, 'bp br') then
npcHandler:say('Do you want to buy a backpack of blank rune for 200 gold coins?')
talk_state = 7
elseif msgcontains(msg, 'yes') and talk_state == 7 then
if getPlayerMoney(cid) >= 200 then
brown_bp = doPlayerAddItem(cid, 2003, 1)
doAddContainerItem(brown_bp, 2260, 20)
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
return true
end
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm Xodet, the owner of this shop."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorcerer and trade with all kinds of magic items."})
keywordHandler:addKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "There is a sorcerer guild in Thais. Just go in the east of the town, it is easly to find."})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm selling life and mana fluids, runes, wands, rods and spellbooks."})
keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm selling life and mana fluids, runes, wands, rods and spellbooks."})
keywordHandler:addKeyword({'have'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm selling life and mana fluids, runes, wands, rods and spellbooks."})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())