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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local qntdade = 600
local stoTime = 96586
local stoKill = 96587
local premio = 100000 --em exp!
local msg = string.lower(msg)
local left = math.ceil((getPlayerStorageValue(cid, stoTime) - os.time())/(24 * 60 * 60)) --nao mexe!
if (msgcontains(msg, 'tarefa') or msgcontains(msg, 'missao')) then
if getPlayerStorageValue(cid, stoTime) ~= -1 and left > 0 and getPlayerStorageValue(cid, stoKill) > 0 then
local faltaMatar = getPlayerStorageValue(cid, stoKill)
local jaMatou = math.abs(getPlayerStorageValue(cid, stoKill)-qntdade)
local prazo = os.date("%d/%m/%y %X", getPlayerStorageValue(cid, stoTime))
selfSay("Você ainda não matou os "..qntdade.." multis, atualmente você matou ".. (jaMatou)..", resta "..faltaMatar..". Seu prazo é de até "..prazo..".", cid)
talkState[talkUser] = 0
return true
elseif getPlayerStorageValue(cid, stoTime) ~= -1 and left <= 0 and getPlayerStorageValue(cid, stoKill) ~= -1 then
selfSay("Infelismente você não matou as "..qntdade.." multis a tempo. Se você quiser, você pode tentar fazer denovo a missao.", cid)
setPlayerStorageValue(cid, stoTime, -1)
setPlayerStorageValue(cid, stoKill, -1)
talkState[talkUser] = 0
return true
elseif getPlayerStorageValue(cid, stoTime) ~= -1 and left > 0 and getPlayerStorageValue(cid, stoKill) == -1 then
local prazo = os.date("%d/%m/%y %X", getPlayerStorageValue(cid, stoTime))
selfSay("Você tem que esperar pelo menos 1 semana para poder pegar essa tarefa denovo. O prazo de acaba dia ".. prazo..".", cid)
talkState[talkUser] = 0
return true
elseif getPlayerStorageValue(cid, stoTime) ~= -1 and left > 0 and getPlayerStorageValue(cid, stoKill) == 0 then
selfSay("Obrigado! você matou os "..qntdade.." multis em menos de 1 semana. Aqui esta sua recompensa! Lembre-se que você pode fazer esta task quantas vezes quiser,desde que tenha concluído 1 semana contado a partir do dia de inicio.", cid)
doPlayerAddExp(cid, premio) --premio
setPlayerStorageValue(cid, stoKill, -1)
talkState[talkUser] = 0
return true
else
if getPlayerStorageValue(cid, stoTime) ~= -1 and getPlayerStorageValue(cid, stoKill) == -1 then
setPlayerStorageValue(cid, stoTime, -1) --soh pra evitar problemas...
end
selfSay("Você quer me ajudar a acabar com poderosas gosmas chamadas Multi?", cid)
talkState[talkUser] = 1
end
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then
selfSay("Ótimo! Você precisa matar pelo menos "..qntdade.." Multis em um prazo de 1 semana para eu te dar a recompensa. Aceita?", cid)
talkState[talkUser] = 2
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 2 then
local semana = 7 * 24 * 60 * 60
setPlayerStorageValue(cid, stoTime, os.time()+semana)
setPlayerStorageValue(cid, stoKill, qntdade)
local sto = getPlayerStorageValue(cid, stoTime)
selfSay("Você já pode começar a matar os multis, mas cuidado! É uma criatura muito forte. Volte aqui quando matar "..qntdade.." multis para ser recompensado. O prazo é até ".. os.date("%d/%m/%y %X", sto) ..".", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())