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
if msgcontains(msg, 'bp of sd') or msgcontains(msg, 'backpack sd') or msgcontains(msg, 'backpack of sudden death runes') then
selfSay('Do you want buy bacpack of sudden death runes for 9000gp?')
talk_state = 1
elseif msgcontains(msg, 'bp of uh') or msgcontains(msg, 'backpack uh') then
selfSay('Do you want buy backpack of ultimate healing runes for 6500gp?')
talk_state = 2
elseif msgcontains(msg, 'bp of explo') or msgcontains(msg, 'backpack explo') or msgcontains(msg, 'bp explosion') or msgcontains(msg, 'bacpack explosion') then
selfSay('Do you want buy bacpack of explosion runes for 8000gp?')
talk_state = 3
elseif msgcontains(msg, 'bp of hmm') or msgcontains(msg, 'backpack hmm') then
selfSay('Do you want buy backpack of heavy magic missile runes for 5000gp?')
talk_state = 4
elseif msgcontains(msg, 'bp of gfb') or msgcontains(msg, 'backpack gfb') then
selfSay('Do you want buy backpack of great fireball runes for 7000gp?')
talk_state = 5
elseif msgcontains(msg, 'bp of manafluid') then
selfSay('Do you want buy backpack of manafluids for 2000gp?')
talk_state = 6
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
buyContainer(cid,5926,2268,5,9000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
buyContainer(cid,5949,2273,5,6500)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
buyContainer(cid,2000,2313,15,8000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
buyContainer(cid,2001,2311,5,5000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
buyContainer(cid,2000,2304,2,7000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 6 then
buyContainer(cid,2001,2006,7,2000)
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) 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())