• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X talkaction to show the date you can do the quest again

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
i have this amazing quest system, where players can do quests more then one time, i mean
you can do katana quest on rookgaard each 10 hours, it is working for every quest

quests.lua
Code:
local mins = 60
local hours = 60 * 60
local days = 24 * 60 * 60
local quests = {
    -- /data/creaturescripts/quests.lua
    -- rook
    [8000] = { name = "Sabre Rook", item = 2385, lvl = 1, time = 15 * mins},
    [8001] = { name = "Doublet Rook", item = 2485, lvl = 2, time = 30 * mins},
    [8002] = { name = "Studded Shield Rook", item = 2526, lvl = 3, time = 50 * mins},
    [8003] = { name = "Copper Shield Rook", item = 2530, lvl = 5, time = 3 * hours},
    [8004] = { name = "Legion Helmet Rook", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours},
}
function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    local levelRequired, quest, level = isLevelRequired(quests[item.actionid])
    if levelRequired then
        if getPlayerLevel(cid) < level then
            doPlayerSendCancel(cid, "Sorry, level: " .. level .. " or higher to complete this quest.")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            return true
        end
    end
    if quest then
        local storage = 200000 + item.actionid
        local quest = quests[item.actionid]
        if quest then
            local timeNow = os.time()
            if timeNow - getPlayerStorageValue(cid, item.actionid) >= 0 then
                if getPlayerFreeCap(cid) >= getItemWeightById(quest.item, 1) then
                    doPlayerAddItem(cid, quest.item, 1)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '..getItemNameById(quest.item)..'.')
                    setPlayerStorageValue(cid, item.actionid, timeNow + quest.time)
                else
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '..getItemNameById(quest.item)..'. It weighs '..getItemWeightById(quest.item, 1)..'.00 and it is too heavy.')         
                end
            elseif getPlayerStorageValue(cid, item.actionid) < 0 then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
            elseif getPlayerStorageValue(cid, item.actionid)-timeNow > days then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/days) ..' days to do it again.')
            elseif getPlayerStorageValue(cid, item.actionid)-timeNow > hours then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/hours) ..' hours to do it again.')
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/mins) ..' minutes to do it again.')
            end
        end
    end
    return true
end

i need some help to create a command /quests
to show:
Code:
--- BLOCKED QUESTS ---
[Katana Rook]: Fri Sep 11 2020 16:28:53 GMT-0300 (Brasilia Standard Time)
[Doublet Rook]: Fri Sep 12 2020 16:38:53 GMT-0300 (Brasilia Standard Time)
 
While I didn't bother making whole thing, part of your original script contains function you would use

getPlayerStorageValue(cid, item.actionid)-timeNow > time_frame then

.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/time_frame) ..'

This is pretty much it.

Just set days, hours, minutes as variables; then get date and add days, hours, minutes or just show player needs to wait X days, Y hours, Z minutes
 
Back
Top