local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local talkState = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local price = 50000
if(msgcontains(msg, "blessings")) then
npcHandler:say("Would you like to buy all blessings for the price of " .. price .. "?", cid)
talkState[talkUser] = 1
if(msgcontains(msg, "yes")) then
local p = Player(cid)
if(p:getMoney() >= price) then
for i = 1,5 do
if(not p:hasBlessing(i)) then
p:addBlessings(i)
else
npcHandler:say("You have already recived my blessings!", cid)
end
end
else
npcHandler:say("You can not afford my blessings!", cid)
end
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())