Advertisement
Guest User

Daily Quest

a guest
Mar 17th, 2015
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. function onUse(cid, item, fromPosition, itemEx, toPosition)
  2.     local config = {
  3.         storage = 45392,
  4.         exstorage = 40822,
  5.         days = {
  6.             ["Monday"] = {
  7.                 {itemid = 8839, count = math.random(1, 3)},
  8.             },
  9.             ["Tuesday"] = {
  10.                 {itemid = 2681, count = 1},
  11.                 {itemid = 2682, count = 1},
  12.                 {itemid = 2683, count = 1}
  13.             },
  14.             ["Wednesday"] = {
  15.                 {itemid = 2674, count = math.random(1, 10)},
  16.                 {itemid = 2675, count = math.random(1, 10)},
  17.                 {itemid = 2676, count = math.random(1, 10)},
  18.                 {itemid = 2673, count = math.random(1, 10)}
  19.             },
  20.             ["Thursday"] = {
  21.                 {itemid = 2679, count = math.random(2, 15)},
  22.                 {itemid = 2680, count = math.random(1, 5)},
  23.             },
  24.             ["Friday"] = {
  25.                 {itemid = 2788, count = math.random(1, 3)},
  26.             },
  27.             ["Saturday"] = {
  28.                 {itemid = 6393, count = 1},
  29.             },
  30.             ["Sunday"] = {
  31.                 {itemid = 2389, count = math.random(2, 12)},
  32.                 {itemid = 2690, count = math.random(1, 5)},
  33.             }
  34.         }
  35.     }
  36.  
  37.      local x = config.days[os.date("%A"]
  38.      if getPlayerStorageValue(cid, config.storage) == tonumber(os.date("%w")) and exhaustion.check(cid, config.exstorage) then
  39.          return doPlayerSendCancel(cid, "The chest is empty, come back tomorrow for a new reward.")
  40.      end
  41.      local c = math.random(#x)
  42.      local info = getItemInfo(x[c].itemid)
  43.      if x[c].count > 1 then
  44.          text = x[c].count .. " " .. info.plural
  45.      else
  46.          text = info.article .. " " .. info.name
  47.      end
  48.      local itemx = doCreateItemEx(x[c].itemid, x[c].count)
  49.      if doPlayerAddItemEx(cid, itemx, false) ~= RETURNVALUE_NOERROR then
  50.          doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  51.          text = "You have found a reward weighing " .. getItemWeight(item) .. " oz. It is too heavy or you have not enough space."
  52.      else
  53.          text = "You have received " .. text .. "."
  54.          setPlayerStorageValue(cid, config.storage, tonumber(os.date("%w")))
  55.          exhaustion.set(cid, config.exstorage, 24*60*60)
  56.      end
  57.      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
  58.      return true
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement