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, 'golden helmet') or msgcontains(msg, 'trade')) then
selfSay("I will trade a piggy bank for your golden helmet. Deal?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'deal') or msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveItem(cid,2471,1) == TRUE then
selfSay('Take this piggybank as a reward!')
doPlayerAddItem(cid, 2508, 1)
else
selfSay('You do not have the required item.')
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay("Then not, gtfo.", cid)
talkState[talkUser] = 0
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())