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(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'offer') then
selfSay('{Equipments Upgrading Gem} for 25 uber tokens and {Weapons Upgrading Gem} for 30 uber tokens.', cid)
elseif msgcontains(msg, 'Equipments Upgrading Gem') then
if getPlayerItemCount(cid,302) >= 25 then
selfSay('Did you bring me the {25} uber tokens ?', cid)
talk_state = 1
else
selfSay('I need {25} uber tokens, to give you the {Equipments Upgrading Gem}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,302) >= 25 then
if doPlayerRemoveItem(cid,302, 25) == TRUE then
selfSay('Take your {Equipments Upgrading Gem}.', cid)
doPlayerAddItem(cid, 7761, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'Weapons Upgrading Gem') then
if getPlayerItemCount(cid,302) >= 30 then
selfSay('Did you bring me the {30} uber tokens ?', cid)
talk_state = 2
else
selfSay('I need {30} uber tokens, to give you the {Weapons Upgrading Gem}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,302) >= 30 then
if doPlayerRemoveItem(cid,302, 30) == TRUE then
selfSay('Take your {Weapons Upgrading Gem}.', cid)
doPlayerAddItem(cid, 7760, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'weapons upgrading gem') then
if getPlayerItemCount(cid,302) >= 30 then
selfSay('Did you bring me the {30} uber tokens ?', cid)
talk_state = 3
else
selfSay('I need {30} uber tokens, to give you the {Weapons Upgrading Gem}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,302) >= 30 then
if doPlayerRemoveItem(cid,302, 30) == TRUE then
selfSay('Take your {Weapons Upgrading Gem}.', cid)
doPlayerAddItem(cid, 7760, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'equipments upgrading gem') then
if getPlayerItemCount(cid,302) >= 25 then
selfSay('Did you bring me the {25} uber tokens ?', cid)
talk_state = 4
else
selfSay('I need {25} uber tokens, to give you the {Equipments Upgrading Gem}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 4 then
talk_state = 0
if getPlayerItemCount(cid,302) >= 25 then
if doPlayerRemoveItem(cid,302, 25) == TRUE then
selfSay('Take your {Equipments Upgrading Gem}.', cid)
doPlayerAddItem(cid, 7761, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 4) then
selfSay('Ok then.', cid)
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())