local config = {
storage = 27364,
exhauststorage = 20932,
days = {
["Monday"] = {itemid = 2476, count = 1, storagevalue = 1},
["Tuesday"] = {itemid = 2488, count = 1, storagevalue = 2},
["Wednesday"] = {itemid = 2195, count = 1, storagevalue = 3},
["Thursday"] = {itemid = 2497, count = 1, storagevalue = 4},
["Friday"] = {itemid = 2270, count = 1, storagevalue = 5},
["Saturday"] = {itemid = 2141, count = 1, storagevalue = 6},
["Sunday"] = {itemid = 2656, count = 1, storagevalue = 7}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local x = config.days[os.date("%A",os.time())]
if(not x) then
print("[Error - Action Interface Daily Quest] - Day not found, write the days in English.")
return true
end
if(getPlayerStorageValue(cid, config.storage) == x.storagevalue and exhaustion.check(cid, config.exhauststorage)) then
return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.")
end
local info = getItemInfo(x.itemid)
if(x.count > 1) then
text = x.count .. " " .. info.plural
else
text = info.article .. " " .. info.name
end
local item = doCreateItemEx(x.itemid, x.count)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
text = "You have found a reward weighing " .. getItemWeight(item) .. " oz. It is too heavy or you have not enough space."
else
text = "You have received " .. text .. "."
setPlayerStorageValue(cid, config.storage, x.storagevalue)
exhaustion.set(cid, config.exhauststorage, 24*60*60)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
return true
end