• 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!

Quest time on quest log

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
I found here on forum this amazing quest system, where players can do a quest more then one time.
It just need to wait a time to do again, but this time only shows when player try to open the chest.

I have i idea, but no idea how to make it possible

How to add this quests on questlog and on quest log description shows the time left to do the quest again?

Code:
local mins = 60
local hours = 60 * 60
local days = 24 * 60 * 60
local quests = {
    -- /data/creaturescripts/quests.lua
    -- rook
    [8000] = { item = 2385, lvl = 1, time = 15 * mins}, -- sabre
    [8001] = { item = 2485, lvl = 2, time = 30 * mins}, -- doublet
    [8002] = { item = 2526, lvl = 3, time = 50 * mins}, -- studded shield
    [8003] = { item = 2530, lvl = 5, time = 3 * hours}, -- copper shield
    [8004] = { item = 2480, lvl = 5, time = 5 * hours}, -- legion helmet
    [8005] = { item = 2412, lvl = 5, time = 10 * hours}, -- katana
}
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


Add something like:
Code:
[8000] = { name = "katana", item = 2385, lvl = 1, time = 15 * mins}, -- sabre


And on Katana's quest log shows time left to do again just like on:
Code:
            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
 
So should i just change the data/xml/quests.xml to: https://pastebin.com/raw/CqfThQfV

???

And on quests.lua, what should i do to show the time left?
You can use the online lua tool like: repl.it
Use Mkalo's tool with the variable xml changed for you quests.xml to get you quests in lua format.
Make a Quests.lua file in LiB Folder that will store all you quests in lua format (that u got what I said previously) and use in you scripts.
 

Similar threads

Back
Top