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 answer = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
elseif (msgcontains(msg, 'crystal sword') or msgcontains(msg, 'broad sword') or msgcontains(msg, 'broadsword') or msgcontains(msg, 'crimson sword'))then
if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
answer = 1
selfSay("Did you brought both items I asked?",cid)
else
selfSay("You need a broad sword and crimson sword to this opearation.",cid)
end
elseif msgcontains(msg, 'yes') and answer == 1 then
if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
local random = math.random(1,100)
doPlayerTakeItem(cid, 2413, 1)
doPlayerTakeItem(cid, 7385, 1)
if random >= 50 then
doPlayerAddItem(cid, 7449, 1)
selfSay("Here you are.",cid)
else
selfSay("Melting ended up failure.",cid)
end
else
selfSay("Come on, do not hide your stuff as a child.",cid)
end
answer = nil
elseif msgcontains(msg, 'no') and answer == 1 then
npcHandler:say('As you wish. Is there something else I can do for you?', cid)
answer = nil
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())