local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 greetCallback(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Topic[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
elseif Topic[talkUser] == 1 then
if msgcontains(msg, "yes") then
local v = true
for i = 2335, 2341 do
if(getPlayerItemCount(cid, i) < 1) then
v = false
break
end
end
if(v) then
for i = 2335, 2341 do
doPlayerRemoveItem(cid, i, 1)
end
npcHandler:say("Thank you. Here it is.", cid)
doPlayerAddItem(cid, 2342, 1)
else
npcHandler:say("You don't have them all.", cid)
end
else
npcHandler:say("Then not.", cid)
end
Topic[talkUser] = 0
elseif msgcontains(msg, "trade") or msgcontains(msg, "helmet") or msgcontains(msg, "piece") then
npcHandler:say("Have you brought me all 7 pieces of the helmet?", cid)
Topic[talkUser] = 1
end
return TRUE
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())