local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
local SORCERER_VOCATION = 1
local DRUID_VOCATION = 2
local PALADIN_VOCATION = 3
local KNIGHT_VOCATION = 4
local MAGE_VOCATION = 5
local RANGER_VOCATION = 6
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "promote") or msgcontains(msg, "promotion") and not talkState[talkUser] > 0 then
if getPlayerVocation(cid) == MAGE_VOCATION then
selfSay("I see you are a mage, I can promote you to either a 'sorcerer' or a 'druid', which path do you want to follow?", cid)
talkState[talkUser] = 10
elseif getPlayerVocation(cid) == RANGER_VOCATION then
selfSay("I see you are a ranger, I can promote you to either a 'paladin' or a 'knight', which path do you want to follow?", cid)
talkState[talkUser] = 20
end
elseif(msgcontains(msg, "sorcerer") and talkState[talkUser] == 10) then
selfSay("A sorcerer, are you sure?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "druid") and talkState[talkUser] == 10) then
selfSay("A druid, are you sure?", cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, "paladin") and talkState[talkUser] == 20) then
selfSay("A paladin, are you sure?", cid)
talkState[talkUser] = 3
elseif(msgcontains(msg, "knight") and talkState[talkUser] == 20) then
selfSay("A knight, are you sure?", cid)
talkState[talkUser] = 4
elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 4 then
selfSay("Very well, your choice has been made!", cid)
setPlayerVocation(cid, talkState[talkUser])
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] >= 1 and talkState[talkUser] <= 4 then
selfSay("I know it is a big decision, please do take your time.", cid)
talkState[talkUser] = 0
else
selfSay("I'm sorry, but I couldn't understand what you said, please start over.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())