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 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, "knight") then
if(getPlayerVocation(cid) == 0) then
selfSay('This is one of your life decision and it\'s irreversible. Are you sure '.. getPlayerName(cid) ..'?', cid)
talkState[talkUser] = 1
else
selfSay('Sorry. You already have a vocation, I can\'t help you right now.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, "no") and talkState[talkUser] == 1) then
npcHandler:onFarewell(cid)
talkState[talkUser] = 0
elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) then
selfSay("I ASK AGAIN, IS THAT YOUR FINAL DECISION?", cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, "no") and talkState[talkUser] == 2) then
npcHandler:onFarewell(cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
if(getPlayerVocation(cid) == 0) then
doPlayerSetVocation(cid, 4)
selfSay("Great! Now, you're one of us!", cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())