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)
Topic[cid] = 0
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
elseif msgcontains(msg, 'egg') or msgcontains(msg, 'magic egg') or msgcontains(msg, 'trade') then
selfSay('Do you want trade {100 eggs} for {25 magic eggs} ?', cid)
Topic[cid] = 1
elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
if doPlayerRemoveItem(cid, 2160, 100) then
doPlayerAddItem(cid, 2155, 25)
selfSay('Hmpf! <smoke weed> huh! Good grass baby!', cid)
else
selfSay('Sorry, you don\'t have {100 eggs}!', cid)
end
Topic[cid] = 0
elseif msgcontains(msg, 'no') and Topic[cid] > 0 then
Topic[cid] = 0
selfSay('Bless ya!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())