local talkNode = 0
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos) npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature) npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id) npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature) npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature) npcHandler:onCreatureChangeOutfit(creature) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
local queststatus = getPlayerStorageValue(cid, 7539)
-- getmission --
if msgcontains(msg, 'mission') then
if queststatus < 1 then
npcHandler:say("Do you want to join the post service?")
talkNode = 1
end
end
-- Confirm yes --
if msgcontains(msg, 'yes') then
if talkNode == 1 then
if queststatus < 1 then
npcHandler:say("Welcome in!")
setPlayerStorageValue(cid, 7539, 1)
focus = 0
talkNode = 0
else
npcHandler:say("Get lost!")
end
end
-- Confirm no --
if msgcontains(msg, 'no') then
if talkNode == 1 then
selfSay('Come back when you have grown up!')
talk_state = 0
end
end
return TRUE
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())