Tested with TFS 1.0 and TFS 1.1
Every day people can get a different reward from the chest, which reward depens on which day it is.
You can add 1 or more items to 1 day. With more items people will get 1 of those items randomly so they won't always get the same item on a certain day.
It can be used in an actual quest so people can do it more often to get more rewards or be a part of something where people need certain items.
actions.xml
dailyquest.lua
For older versions: http://pastebin.com/TJT0uYiT
Every day people can get a different reward from the chest, which reward depens on which day it is.
You can add 1 or more items to 1 day. With more items people will get 1 of those items randomly so they won't always get the same item on a certain day.
It can be used in an actual quest so people can do it more often to get more rewards or be a part of something where people need certain items.
actions.xml
Code:
<action uniqueid="3001" script="quests/dailyquest.lua"/>
dailyquest.lua
Code:
local config = {
storage = 45392,
exstorage = 40822,
days = {
["Monday"] = {
{itemid = 8839, count = {1, 3}}
},
["Tuesday"] = {
{itemid = 2681, count = {1}},
{itemid = 2682, count = {1}},
{itemid = 2683, count = {1}}
},
["Wednesday"] = {
{itemid = 2674, count = {1, 10}},
{itemid = 2675, count = {1, 10}},
{itemid = 2676, count = {1, 10}},
{itemid = 2673, count = {1, 10}}
},
["Thursday"] = {
{itemid = 2679, count = {2, 15}},
{itemid = 2680, count = {1, 5}}
},
["Friday"] = {
{itemid = 2788, count = {1, 3}}
},
["Saturday"] = {
{itemid = 6393, count = {1}}
},
["Sunday"] = {
{itemid = 2389, count = {2, 12}},
{itemid = 2690, count = {1, 5}}
}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
local player = Player(cid)
local x = config.days[os.date("%A")]
if player:getStorageValue(config.storage) == tonumber(os.date("%w")) and player:getStorageValue(config.exstorage) > os.time() then
return player:sendCancelMessage("The chest is empty, come back tomorrow for a new reward.")
end
local c = math.random(#x)
local info, count = ItemType(x[c].itemid), x[c].count[2] and math.random(x[c].count[1], x[c].count[2]) or x[c].count[1]
if count > 1 then
text = count .. " " .. info:getPluralName()
else
text = info:getArticle() .. " " .. info:getName()
end
local itemx = Game.createItem(x[c].itemid, count)
if player:addItemEx(itemx) ~= RETURNVALUE_NOERROR then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
text = "You have found a reward weighing " .. itemx:getWeight() .. " oz. It is too heavy or you have not enough space."
else
text = "You have received " .. text .. "."
player:setStorageValue(config.storage, tonumber(os.date("%w")))
player:setStorageValue(config.exstorage, os.time() + 24*60*60)
end
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
return true
end
For older versions: http://pastebin.com/TJT0uYiT
Last edited: