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)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
addon_need_premium = 'Sorry, you need a Higher Level'
addon_have_already = 'Sorry, i have already knighted you'
addon_have_not_items = 'Sorry, you don\'t have what i require to help you'
addon_give = 'You are now promoted'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'power') then
selfSay('I am the the king of this town and i can bless you and make you a Noble Guard of mine.')
elseif msgcontains(msg, 'help') then
selfSay('Say promote, and i will.')
------------------------------------------------ addon ------------------------------------------------
elseif msgcontains(msg, 'promot') then
if player_money >= 20000 then
selfSay('Would you like to be promoted for 20000 gold peices?')
talk_state = 1
else
selfSay('i will promote you for 20000 gold coins, nor more, no less!')
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
addon = getPlayerStorageValue(cid,30018)
if addon >= -1 then
if doPlayerRemoveMoney(cid, 20000) then
voc = getPlayerVocation(cid)
voc = 1
doPlayerSetVocation(cid,voc)
setPlayerStorageValue(cid,30018,1)
selfSay(addon_give)
else
selfSay(addon_have_not_items)
end
else
selfSay(addon_have_already)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())