local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 items = { ["demon armor"] = { cost = 5906, count = 50}, -- [itemid]
["demon legs"] = {cost = 5906, count = 50},
["demon helmet"] = {cost = 5906, count = 20}
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'reward') then
selfSay("Then, I assume you have some demon dusts for me right?",cid)
talkState[talkUser] =1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
selfSay("I exchange : {Demon Armor} for 50 dmeon dusts, {Demon Legs} for 50 dmeon dusts, {Demon Helemt} for 20 demon dusts.",cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
selfSay("Then, Why are you bothering me?!.",cid)
talkState[talkUser] = 0
end
for k, v in pairs(items) do
if msgcontains(msg, k) and talkState[talkUser] == 3 then
if not doPlayerRemoveItem(cid, v.cost,v.count) then
selfSay("Seems you dont have ".. v.count .." x demon dusts.Go away noob!.",cid)
talkState[talkUser] = 0
else
doPlayerAddItem(cid,getItemIdByName(k),1)
selfSay("Here you are.",cid)
talkState[talkUser] = 0
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())