local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() 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
if msgcontains(msg, 'arena') then
selfSay('For 1000 gp i may give you permission to Greenhorn level. For 5000 gp i give you permission to Scrapper level. Warlord level is for 10000 gp.')
elseif msgcontains(msg, 'greenhorn') then
selfSay('Do you want permission to Greenhorn level for 1000 gp?')
talk_state = 1
elseif msgcontains(msg, 'scrapper') then
selfSay('Do you want permission to Scrapper level for 5000 gp?')
talk_state = 2
elseif msgcontains(msg, 'warlord') then
selfSay('Do you want permission to Warlord level for 10000 gp?')
talk_state = 3
-- --------------------------------- confirm yes ----------------------
elseif msgcontains(msg, 'yes') then
if talk_state == 1 then
doPlayerRemoveMoney(cid,1000)
setPlayerStorageValue(cid, 5029, 1)
selfSay('Here you go.')
elseif talk_state == 2 then
doPlayerRemoveMoney(cid,5000)
setPlayerStorageValue(cid, 5029, 2)
selfSay('Here you go.')
elseif talk_state == 3 then
doPlayerRemoveMoney(cid,10000)
setPlayerStorageValue(cid, 5029, 3)
selfSay('Here you go.')
end
-- -----------------------------------confirm no ---------------------------
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())