local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
local t = {
id = 2563,
storage = 9001,
money = 15,
rewardMoney = 5,
rewardExp = 50
}
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, 'pan') or msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
local v = getPlayerStorageValue(cid, storage)
if v < 1 then
selfSay('Do you want to do a favor for me?', cid)
Topic[cid] = 1
elseif v == 1 then
selfSay('Have you brought me a ' .. getItemNameById(t.id) .. '?', cid)
Topic[cid] = 2
elseif v == 2 then
selfSay('You\'ve already helped me.', cid)
end
elseif Topic[cid] == 1 then
if msgcontains(msg, 'yes') then
selfSay('Here\'s your money, I need you to buy a ' .. getItemNameById(t.id) .. ' for me!', cid)
doPlayerAddMoney(cid, t.money)
setPlayerStorageValue(cid, storage, 1)
else
selfSay('Maybe later.', cid)
end
Topic[cid] = 0
elseif Topic[cid] == 2 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, t.id, 1) then
selfSay('Thank you, here is your reward!', cid)
if t.rewardMoney then
doPlayerAddMoney(cid, t.rewardMoney)
end
if t.rewardExp then
doPlayerAddExp(cid, t.rewardExp)
doSendAnimatedText(getThingPos(cid), t.rewardExp, COLOR_WHITE)
end
setPlayerStorageValue(cid, storage, 2)
else
selfSay('You don\'t have it!', cid)
end
else
selfSay('Then what are you waiting for?', cid)
end
Topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())