Action Daily Quest (different reward every day)

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
533
Confirmed working on 1.1.

The ID to that chest is w/e you make it because its a custom sprite ;)
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,758
Solutions
186
Reaction score
3,556
The ones limos posted? Aint they custom sprites? hence why he posted them? o.0
if you mean the sprite, it is not custom, it got added in rl tibia in 10.2 version, and she posted only the script, that is custom since there is no free script for the reward chest in real tibia I guess, tfs is still discussing it here :p
 
OP
Limos

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,018
Solutions
8
Reaction score
3,017
Location
Netherlands
whats the id to that chest?
The ID of the chest is 21584. The plant is 19653.

The ones limos posted? Aint they custom sprites? hence why he posted them? o.0
It's just an image for the script, to give a first impression or idea how this could be used.
 

J.Dre

Project Manager
Joined
May 18, 2011
Messages
2,630
Solutions
2
Reaction score
585
Location
United States
Tested with TFS 1.0


latest
latest
latest



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:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
     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 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 = ItemType(x[c].itemid)
     if x[c].count > 1 then
         text = x[c].count .. " " .. info:getPluralName()
     else
         text = info:getArticle() .. " " .. info:getName()
     end
     local itemx = Game.createItem(x[c].itemid, x[c].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/mZj4r7cF

Very cool script, but you shouldn't put the config inside the script because every time the script executes it has to run through the entire config, which is a waste of system resources. Instead, you can assign: count = {1, 3} and then do: math.random(count[1], count[2]) within the script, which also eliminates the need for so many "math.random" executions for each item.

Pretty sure you can write it yourself, so I didn't do so. But that will definitely help. :cool:
 
OP
Limos

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,018
Solutions
8
Reaction score
3,017
Location
Netherlands
Very cool script, but you shouldn't put the config inside the script because every time the script executes it has to run through the entire config, which is a waste of system resources. Instead, you can assign: count = {1, 3} and then do: math.random(count[1], count[2]) within the script, which also eliminates the need for so many "math.random" executions for each item.

Pretty sure you can write it yourself, so I didn't do so. But that will definitely help. :cool:
I'm aware of that (I think almost everyone is :rolleyes:), I just did it for the math.random ofc. I had it first without math.random, then I though it would be nice if people can get different amounts, so added some math.random as example and placed it under the function. But it's a good idea, updated main post.
 

EwR

New Member
Joined
Aug 28, 2013
Messages
94
Reaction score
3
The only thing i need to do is put actionID: 3001 and uniqueID: 3001? in the chest?
 
OP
Limos

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,018
Solutions
8
Reaction score
3,017
Location
Netherlands
Only uniqueid 3001, you can also use an other one btw, it's just as example, but there is only 1 id used, so there is no need for both uniqueid and actionid.
 

Tarek1337

Legendary OT User
Joined
Jun 9, 2012
Messages
3,584
Solutions
3
Reaction score
1,163
Location
Sweden
Only uniqueid 3001, you can also use an other one btw, it's just as example, but there is only 1 id used, so there is no need for both uniqueid and actionid.
It's possible to fix so you can get a achievement after opening 50 Daily quests chests? (fml just killed my english.)
 
OP
Limos

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,018
Solutions
8
Reaction score
3,017
Location
Netherlands
Yes, you can just add an extra storage that sets the value +1 till it's 49 and then add the achievement.
 
Top