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 config = {
storage = 27394,
exhauststorage = 20938,
days = {
["Monday"] = {itemid = 2674, count = 20, storagevalue = 1},
["Tuesday"] = {itemid = 2676, count = 20, storagevalue = 2},
["Wednesday"] = {itemid = 2673, count = 20, storagevalue = 3},
["Thursday"] = {itemid = 2680, count = 20, storagevalue = 4},
["Friday"] = {itemid = 2675, count = 20, storagevalue = 5},
["Saturday"] = {itemid = 2680, count = 20, storagevalue = 6},
["Sunday"] = {itemid = 5097, count = 20, storagevalue = 7}
}
}
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local x = config.days[os.date("%A")]
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local info = getItemInfo(x.itemid)
if x.count > 1 then
text = x.count .. " " .. info.plural
else
text = info.article .. " " .. info.name
end
if msgcontains(msg, "mission") then
if getPlayerStorageValue(cid, config.storage) == x.storagevalue and exhaustion.check(cid, config.exhauststorage) then
selfSay("You already did a mission today, come back tomorrow for a new mission.", cid)
elseif getPlayerStorageValue(cid, storage) ~= x.storagevalue * 2 then
selfSay("I need "..text..", can you get it for me?", cid)
talkState[talkUser] = 1
else
selfSay("Did you get "..text.."?", cid)
talkState[talkUser] = 1
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) ~= x.storagevalue * 2 then
selfSay("Thanks alot, come back when you have it.", cid)
setPlayerStorageValue(cid, storage, x.storagevalue * 2)
else
if doPlayerRemoveItem(cid, x.itemid, x.count) then
selfSay("That's great, thanks.", cid)
doPlayerAddItem(cid, 2160, 3)
doPlayerAddExp(cid, 5000)
setPlayerStorageValue(cid, config.storage, x.storagevalue)
exhaustion.set(cid, config.exhauststorage, 24*60*60)
else
selfSay("You don't have it.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] >= 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())