• 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 log on lua 0.4

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.
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

It just need to wait a time to do again, but this time only shows when player try to open the chest.

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

@zxmatzx told me he is using this stuff on 1.0:
He told it change quests.xml to quest.lua, if it work on 0.4 i could show on quest log how many time left to do the quest again

But is it possible to do on 0.4

If it is, how to?
 

Similar threads

Back
Top