local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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
local necromancer_shield = 6433 ----- ID OF necromancer shield
local demonic_essences = 6500 ----- ID OF essences
function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, 'shield') or msgcontains(msg, 'trade')) then
npcHandler:say('Really you change you 3000 demonic essence for me necromancer shield?', cid)
Topic[cid] = 1
elseif msgcontains(msg, 'yes') and getPlayerItemCount(cid,demonic_essences) >= 3000 and Topic[cid] == 1 then
npcHandler:say('Okay, here you go!', cid)
doPlayerRemoveItem(cid,demonic_essences,3000)
doPlayerAddItem(cid,necromancer_shield, 1)
Topic[cid] = 0
elseif msgcontains(msg, 'yes') and getPlayerItemCount(cid,demonic_essences) < 3000 and Topic[cid] == 1 then
npcHandler:say('You do not have the required demonic essences for this trade', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'no') and Topic[cid] == 1 then
npcHandler:say('Then leave', cid)
Topic[cid] = 0
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())