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

I fuckd up my lib. Help

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey guys!

I made something wrone, because of firestorm event.

First, originally I got in my 034-exhaustion:
Lua:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerStorageValue(cid, storage) >= os.time(t)) then
            return TRUE
        end

        return FALSE
    end,

    get = function (cid, storage)
        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time(t)
            if(left >= 0) then
                return left
            end
        end

        return FALSE
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time(t) + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return TRUE
        end

        return FALSE
    end
}

Everything was great, but not the firestorm event, so I searched and I found that I need to change this lib for this:

Lua:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end
        return getPlayerStorageValue(cid, storage) >= os.time(t)
    end,
    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end
        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time(t)
            if(left >= 0) then
                return left
            end
        end
        return false
    end,
    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time(t) + time)
    end,
    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end
        return false
    end
}

And yes, the Firestorm Event is working perfect now, but not my daily reward chest which has a script:
Lua:
-- Time Chest by Limos
local config = {
    exhausttime = 86400, -- time in seconds
    exhauststorage = 2301,
    level = 50 -- minimum level to open the chest
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
    [25] = {
        tilllevel = 50,
        {id = 5957, chance = 5, count = 1}, -- start with the lowest chances
           {id = 12772, chance = 6, count = 1}, -- start with the lowest chances
        {id = 12777, chance = 15, count = math.random(1, 20)},
        {id = 12778, chance = 20, count = math.random(1, 30)},
        {id = 7703, chance = 25, count = 1},
    {id = 2160, chance = 40, count = math.random(1, 5)},
        {id = 2152, chance = 50, count = math.random(1, 50)}
    },
    [50] = {
        tilllevel = 100,
{id = 5957, chance = 5, count = 1}, -- start with the lowest chances
           {id = 12772, chance = 6, count = 1}, -- start with the lowest chances
        {id = 12777, chance = 15, count = math.random(1, 20)},
        {id = 12778, chance = 20, count = math.random(1, 30)},
        {id = 7703, chance = 25, count = 1},
    {id = 2160, chance = 40, count = math.random(1, 5)},
        {id = 2152, chance = 50, count = math.random(1, 50)}
    },
    [100] = {
        tilllevel = 200,
        {id = 5957, chance = 5, count = 1}, -- start with the lowest chances
           {id = 12772, chance = 6, count = 1}, -- start with the lowest chances
        {id = 12777, chance = 15, count = math.random(1, 20)},
        {id = 12778, chance = 20, count = math.random(1, 30)},
        {id = 7703, chance = 25, count = 1},
    {id = 2160, chance = 40, count = math.random(1, 5)},
        {id = 2152, chance = 50, count = math.random(1, 50)}
    },
    [200] = {
        tilllevel = 10000,
        {id = 5957, chance = 5, count = 1}, -- start with the lowest chances
           {id = 12772, chance = 6, count = 1}, -- start with the lowest chances
        {id = 12777, chance = 15, count = math.random(1, 20)},
        {id = 12778, chance = 20, count = math.random(1, 30)},
        {id = 7703, chance = 25, count = 1},
    {id = 2160, chance = 40, count = math.random(1, 5)},
        {id = 2152, chance = 50, count = math.random(1, 50)}
    }
}
    if(getPlayerLevel(cid) < config.level) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.")
        return true
    end
    if(exhaustion.check(cid, config.exhauststorage)) then
        local time = exhaustion.get(cid, config.exhauststorage)
        local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
        if time >= 3600 then
            text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
        elseif time >= 120 then
            text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
        else
            text = seconds.." "..(seconds == 1 and "second" or "seconds")
        end
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.")
        return true
    end
    local chance = math.random(1,100)
    for v, x in pairs(rewarditems) do
        if(getPlayerLevel(cid) >= v and getPlayerLevel(cid) < x.tilllevel) then
            level = v
        end
    end
    for i = 1, #rewarditems[level], 1 do
        if(chance < rewarditems[level][i].chance) then
            local info = getItemInfo(rewarditems[level][i].id)
            if(rewarditems[level][i].count > 1) then  
                text = rewarditems[level][i].count .. " " .. info.plural
            else
                        text = info.article .. " " .. info.name
            end
            local item = doCreateItemEx(rewarditems[level][i].id, rewarditems[level][i].count)
            if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
                doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
                text = "You have found a reward. It is to heavy or you have not enough space."
            else
                text = "You have found " .. text .. "."
                exhaustion.set(cid, config.exhauststorage, config.exhausttime)
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
            return true
        else
            chance = chance - rewarditems[level][i].chance
        end
    end
end

Now, I can get items from there anytime, not to worry about 24 hours. Can someone split the libs or make something to works together these two scripts please?
 
Back
Top