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 msgcontains(msg, 'lottery ticket') or msgcontains(msg, 'vial') or msgcontains(msg, 'ticket') or msgcontains(msg, 'lottery') then
if getPlayerItemCount(cid,7636) >= 100 then
if doPlayerRemoveItem(cid,7636,100) == 1 then
selfSay('Here you are. Good luck!')
doPlayerAddItem(cid,5957,1)
end
elseif getPlayerItemCount(cid,7634) >= 100 then
if doPlayerRemoveItem(cid,7634,100) == 1 then
selfSay('Here you are. Good luck!')
doPlayerAddItem(cid,5957,1)
end
elseif getPlayerItemCount(cid,7635) >= 100 then
if doPlayerRemoveItem(cid,7635,100) == 1 then
selfSay('Here you are. Good luck!')
doPlayerAddItem(cid,5957,1)
end
elseif getPlayerItemCount(cid,2006) >= 100 then
if doPlayerRemoveItem(cid,2006,100) == 1 then
selfSay('Here you are. Good luck!')
doPlayerAddItem(cid,5957,1)
end
else
selfSay('I need 100 empty vials to give you a lottery ticket.')
talk_state = 0
end
elseif msgcontains(msg, 'no') then
selfSay('Maybe later.')
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())