local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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(npcHandler.focus ~= cid) then
return 0
end
local Items = {
["magic sword"] = {price = 12, id = 1},
["demon armor"] = {price = 14, id = 1},
["demon helmet"] = {price = 14, id = 1}
}
if(msgcontains(Items[msg])) then
npcHandler:say("do you want to buy a "..msg.." for "..Items[msg].price.." gold?")
talkState[talkUser] = 1
end
return 1
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())