local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local t = {}
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
elseif msgcontains(msg, 'wisdom') then
local v = getPlayerLevel(cid)
if v < 31 then
v = 2000
elseif v > 119 then
v = 20000
else
v = (v - 20) * 200
end
npcHandler:say('I can provide you with the wisdom of solitude. Would you like to receive my blessing for ' .. v .. ' gold?', cid)
t[cid] = 1
elseif t[cid] == 1 then
if msgcontains(msg, 'yes') then
if not getPlayerBlessing(cid, 1) then
local v = getPlayerLevel(cid)
if v < 31 then
v = 2000
elseif v > 119 then
v = 20000
else
v = (v - 20) * 200
end
if doPlayerRemoveMoney(cid, v) then
npcHandler:say('So receive the wisdom of solitude, pilgrim.', cid)
doPlayerAddBlessing(cid, 1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
else
npcHandler:say('Oh. You do not have enough money..', cid)
end
else
npcHandler:say('You already possess this blessing.', cid)
end
else
npcHandler:say('Ok. As you wish.', cid)
end
t[cid] = nil
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())