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
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, 'job') or msgcontains(msg, 'help') then
selfSay('I can give you a "lottery ticket" for empty vials.')
------------------------------------------------ addon ------------------------------------------------
elseif msgcontains(msg, 'lottery ticket') then
if isPremium(cid) then
selfSay('Do you want to exchange great or divine empty potions?')
talk_state = 1
elseif msgcontains(msg, 'great') and talk_state == 1 then
if getPlayerItemCount(cid,7635) >= 50 then
selfSay('Did you bring me 50 empty great potions for a lottery ticket?')
talk_state = 2
else
selfSay('I need 50 empty great potions, to give you the lottery ticket. Come back when you have them.')
talk_state = 0
end
elseif msgcontains(msg, 'divine') and talk_state == 1 then
if getPlayerItemCount(cid, 7634) >= 200 then
selfSay('Did you bring me 200 empty divine potions for a lottery ticket?')
talk_state = 3
else
selfSay('I need 200 empty great potions, to give you the lottery ticket. Come back when you have them.')
talk_state = 0
end
else
selfSay('Ok, then.')
talk_state = 0
end
else
selfSay('I will deal only with premium characters.')
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,7635) >= 200 then
if doPlayerRemoveItem(cid,2006,200) then
doPlayerAddItem(cid,5957,1)
end
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,7634) >= 200 then
if doPlayerRemoveItem(cid,7634,200) then
doPlayerAddItem(cid,5957,1)
end
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())