local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- 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 onThink() npcHandler:onThink() end
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'help') then
selfSay('Here, you can change some items with me.')
elseif msgcontains(msg, 'misterious') then
if getPlayerItemCount(cid,11337) >= 1 and getPlayerItemCount(cid,12426) >= 1 and getPlayerItemCount(cid,11076) >= 1 and getPlayerItemCount(cid,12424) >= 1 then
selfSay('Did you bring me the four misterious item ?')
talk_state = 2
else
selfSay('I need the four misterious item !')
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,11337) >= 1 and getPlayerItemCount(cid,12426) >= 1 and getPlayerItemCount(cid,11076) >= 1 and getPlayerItemCount(cid,12424) >= 1 then
if doPlayerRemoveItem(cid,11337,1) == 1 and doPlayerRemoveItem(cid,12426,1) == 1 and doPlayerRemoveItem(cid,11076,1) == 1 and doPlayerRemoveItem(cid,12424,1) == 1 then
selfSay(addon_give)
doPlayerAddItem(cid,10124,1)
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())