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
function creatureSayCallback(cid, type, msg)
--- TODO: bless function in modules.lua
if(npcHandler.focus ~= cid) then
return FALSE
end
if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
npcHandler:say("I can provide you with "all blessings", just say "all blessings" to buy it.")
talkState = 0
elseif msgcontains(msg, 'all blessings') then
npcHandler:say("Do you want to buy all blessing for 50000 gold?")
talkState = 1
elseif talkState > 0 then
if msgcontains(msg, 'yes') then
if getPlayerBlessing(cid, talkState) then
npcHandler:say("A god has already blessed you with all blessings.")
elseif TRUE == TRUE then
if doPlayerRemoveMoney(cid, 50000) == TRUE then
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
npcHandler:say("You have been blessed by the five gods!")
else
npcHandler:say("You don't have enough money.")
end
else
npcHandler:say("You need a premium account to buy blessings.")
end
talkState = 0
elseif msgcontains(msg, 'no') then
npcHandler:say("Then not.")
talkState = 0
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())