local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local cost = 10
local lvl = 717000
if msgcontains(msg, 'epic promotion') then
if getPlayerItemCount(cid, 2160) >= cost then
if getPlayerLevel(cid) >= lvl then
if getPlayerPromotionLevel(cid) == 1 then
selfSay('Do you want to be promoted to epic ?')
talk_state = 1
else
selfSay('You must be promoted.')
end
else
selfSay('You must have level ".. lvl .." or higher')
end
else
selfSay('You have to pay ".. cost .." crystal coins.')
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid, 2160) >= cost then
if doPlayerRemoveItem(cid, 2160, cost) == TRUE then
selfSay('You are now promoted to epic.')
end
else
selfSay('You don\'t have money.')
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())