Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local config = {
- storage = 45392,
- exstorage = 40822,
- days = {
- ["Monday"] = {
- {itemid = 8839, count = math.random(1, 3)},
- },
- ["Tuesday"] = {
- {itemid = 2681, count = 1},
- {itemid = 2682, count = 1},
- {itemid = 2683, count = 1}
- },
- ["Wednesday"] = {
- {itemid = 2674, count = math.random(1, 10)},
- {itemid = 2675, count = math.random(1, 10)},
- {itemid = 2676, count = math.random(1, 10)},
- {itemid = 2673, count = math.random(1, 10)}
- },
- ["Thursday"] = {
- {itemid = 2679, count = math.random(2, 15)},
- {itemid = 2680, count = math.random(1, 5)},
- },
- ["Friday"] = {
- {itemid = 2788, count = math.random(1, 3)},
- },
- ["Saturday"] = {
- {itemid = 6393, count = 1},
- },
- ["Sunday"] = {
- {itemid = 2389, count = math.random(2, 12)},
- {itemid = 2690, count = math.random(1, 5)},
- }
- }
- }
- local x = config.days[os.date("%A"]
- if getPlayerStorageValue(cid, config.storage) == tonumber(os.date("%w")) and exhaustion.check(cid, config.exstorage) then
- return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.")
- end
- local c = math.random(#x)
- local info = getItemInfo(x[c].itemid)
- if x[c].count > 1 then
- text = x[c].count .. " " .. info.plural
- else
- text = info.article .. " " .. info.name
- end
- local itemx = doCreateItemEx(x[c].itemid, x[c].count)
- if doPlayerAddItemEx(cid, itemx, 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, tonumber(os.date("%w")))
- exhaustion.set(cid, config.exstorage, 24*60*60)
- end
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement