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
if msgcontains(msg, 'help') then
selfSay('Say "help" for more informations.')
elseif msgcontains(msg, 'promotion') then
if getPlayerMoney(cid) >= 20000 then
if getPlayerPromotionLevel(cid) ~= 1 then
selfSay('Do you want to be promoted for 20k?')
talk_state = 1
else
selfSay('You are already promoted.')
talk_state = 0
end
else
selfSay('You don\'t have enough money.')
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerPromotionLevel(cid) ~= 1 then
if doPlayerRemoveMoney(cid, 20000) == TRUE then
doPlayerSetPromotionLevel(cid, 1)
doPlayerSetExperienceRate(cid, 1.0)
selfSay('Here u are.')
else
selfSay('You don\'t have enough money.')
talk_state = 0
end
else
selfSay('You are already promoted.')
talk_state = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())