I have problem with my NPC with spells (TFS 0.3.6):
When I try to buy (when say 'yes') Divine Healing with RP, server printing this:
Code:
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
function creatureSayCallback(cid, type, msg)
local talkUser = cid
if(not npcHandler:isFocused(cid)) then
return false
end
local CONFIG =
{[1] = {spell1='Energy Wave', spell2='Hells Core'},
[5] = {spell1='Energy Wave', spell2='Hells Core'},
[2] = {spell1='Ice Wave', spell2='Ethernal Winter'},
[6] = {spell1='Ice Wave', spell2='Ethernal Winter'},
[3] = {spell1='Divine Healing', spell2='Divine Caldera'},
[7] = {spell1='Divine Healing', spell2='Divine Caldera'},
[4] = {spell1='Wound Cleansing', spell2='Fierce Berserk'},
[8] = {spell1='Wound Cleansing', spell2='Fierce Berserk'}}
if(msgcontains(msg,'spells')) then
selfSay('You are '.. getPlayerVocationName(cid) ..', so I have for you spells: {'.. CONFIG[getPlayerVocation(cid)].spell1 ..'}, {'.. CONFIG[getPlayerVocation(cid)].spell2 ..'}.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
local node1 = keywordHandler:addKeyword({'energy wave'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Energy Wave for 10000 gp?'})
node1:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'energy wave', vocation = 1, price = 10000, level = 38})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node2 = keywordHandler:addKeyword({'hells core'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Hells Core for 50000 gp?'})
node2:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'hells core', vocation = 1, price = 50000, level = 60})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node3 = keywordHandler:addKeyword({'ice wave'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to Ice Wave for 10000 gp?'})
node3:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'ice wave', vocation = 2, price = 10000, level = 18})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node4 = keywordHandler:addKeyword({'ethernal winter'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Ethernal Winter for 50000 gp?'})
node4:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'ethernal winter', vocation = 2, price = 50000, level = 60})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node5 = keywordHandler:addKeyword({'divine healing'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Divine Healing for 10000 gp?'})
node5:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'divine healing', vocation = 3, price = 10000, level = 35})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node6 = keywordHandler:addKeyword({'divide caldera'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Divine Caldera for 50000 gp?'})
node6:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'divide caldera', vocation = 3, price = 50000, level = 50})
node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node7 = keywordHandler:addKeyword({'wound cleansing'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Wound Cleansing for 10000 gp?'})
node7:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'wound cleansing', vocation = 4, price = 10000, level = 30})
node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
local node8 = keywordHandler:addKeyword({'fierce berserk'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to learn Fierce Berserk for 50000 gp?'})
node8:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, premium = true, spellName = 'fierce berserk', vocation = 4, price = 50000, level = 70})
node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Come when you will be prepared.', reset = true})
npcHandler:addModule(FocusModule:new())
When I try to buy (when say 'yes') Divine Healing with RP, server printing this:
I tried to set vocation into '7', but I didn't work.<_<[11/03/2010 19:57:18] [Error - Npc interface]
[11/03/2010 19:57:18] data/npc/scripts/spells.luanCreatureSay
[11/03/2010 19:57:18] Description:
[11/03/2010 19:57:18] data/npc/lib/npcsystem/modules.lua:109: attempt to call field 'vocation' (a nil value)
[11/03/2010 19:57:18] stack traceback:
[11/03/2010 19:57:18] data/npc/lib/npcsystem/modules.lua:109: in function 'callback'
[11/03/2010 19:57:18] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[11/03/2010 19:57:18] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[11/03/2010 19:57:18] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
[11/03/2010 19:57:18] data/npc/lib/npcsystem/npchandler.lua:387: in function 'onCreatureSay'
[11/03/2010 19:57:18] data/npc/scripts/spells.lua:8: in function <data/npc/scripts/spells.lua:8>