Hello, I just started with the "new" npc system and I have a problem. I have a Druid NPC that will give you level 8 and make you a druid. But it doesn't work.
Here is where it went wrong:
Here is the console error message:
Here is the whole code:
Here is where it went wrong:
Code:
If getPlayerVocation(cid) == 0 then
doPlayerSetVocation(cid,2)
doPlayerAddExp(cid, 4200)
end
Here is the console error message:
Code:
[16/03/2012 17:10:38] [Error - LuaScriptInterface::loadFile] data/npc/scripts/druid.lua:53: '=' expected near 'getPlayerVocation'
[16/03/2012 17:10:38] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/druid.lua
[16/03/2012 17:10:38] data/npc/scripts/druid.lua:53: '=' expected near 'getPlayerVocation'
Here is the whole code:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local TopicState = {}
-- 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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
-- Buy
shopModule:addBuyableItem({"Snakebite Rod"}, 2182, 500)
shopModule:addBuyableItem({"Moonlight Rod"}, 2186, 1000)
shopModule:addBuyableItem({"Necrotic Rod"}, 2185, 5000)
shopModule:addBuyableItem({"Northwind Rod"}, 8911, 5000)
shopModule:addBuyableItem({"Hailstorm Rod"}, 2183, 10000)
shopModule:addBuyableItem({"Springsprout Rod"}, 8912, 10000)
shopModule:addBuyableItem({"Underworld Rod"}, 8910, 10000)
shopModule:addBuyableItem({"Terra Rod"}, 2181, 8000)
-- Sell
function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
npcHandler:say("Welcome to the druid headquarter. I'm the Druid Leader and you can talk to me if you are interested in becoming a druid. Just ask me about {druids}.", cid)
npcHandler:addFocus(cid)
TopicState[cid] = 0
elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Good bye, may the gods be with you!", cid, TRUE)
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "druids") then
npcHandler:say("Druids are powerfull magicians who use the powers of earth and ice as their main elements. Do you want to {become} one of us?", cid)
elseif msgcontains(msg, "become") then
npcHandler:say("Are you sure that you want to become a druid? This decision is irreversible.", cid)
elseif msgcontains(msg, "yes") then
If getPlayerVocation(cid) == 0 then
doPlayerSetVocation(cid,2)
doPlayerAddExp(cid, 4200)
end
npcHandler:say("Congratulations you have now become a druid. Upstairs you can find some starting equipment. If you ever need a rod, then you can come and talk to me.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye then.")
npcHandler:setMessage(MESSAGE_SENDTRADE, "Please browse through my wares.")
npcHandler:setMessage(MESSAGE_ONCLOSESHOP, "Pleasure doing business with you!")
npcHandler:setMessage(MESSAGE_IDLETIMEOUT, "Good bye then.")