antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More

Archived

This topic is now archived and is closed to further replies.

  • 0
Marcos Pinheiro

Erro com tempo quest dragon_lair_weekly

Question

Boa noite, ao testar a quest dragon_lair_weekly, ocorre tudo bem até a entrega das esferas da poliformia, quando clico para tentar fazer novamente deveria aparecer o tempo que eu tenhho para poder fazer a missão novamente, mais isso não ocorre e me aparece um erro no syserr.

Eu já pesquisei sobre o erro e até agora não consegui encontrar nada sobre o erro.

 

syserr:

Spoiler

SYSERR: Dec  9 20:56:43.545181 :: RunState: LUA_ERROR: locale/turkey/quest/GFquestlib.lua:65: attempt to index field `time' (a nil value)
SYSERR: Dec  9 20:56:43.549422 :: WriteRunningStateToSyserr: LUA_ERROR: quest dragon_lair_weekly.getquest click

 

GFquestlib.lua:

Spoiler


-- returns a vnum from a table.
-- the table must look like this:
-- items = {
--     {vnum, probability[, minLevel[, maxLevel] ]}[, ...]
-- }
-- vnum is the vnum to be returned
-- probability is an int showing how often this vnum should be returned compared to the others
-- minLevel is the minimum level a player should have in order to return this vnum
-- maxLevel is the maximum level a player should have in order to return this vnum
-- -- WARNING: don't use levelLimit in server_timer triggers, the server will crash!
-- 
-- e.g:
-- items = {
--     {101, 1},
--     {102, 2, 20, 50}
-- }
-- will return vnum 101 with a probability of 1/3. When player is below level 20 the probability will be 1/1.
-- returns 102 with a probability of 2/3 when the player is between level 20 and 50, otherwise not.

function get_random_vnum_from_table(items)
    local temp_table = {}
    local playerLevel = pc.get_level()
    table.foreachi(items, 
        function(index, item)
            local itemProbability = item[2]
            local itemVnum = item[1]
            local meetsLevelLimit = true
            if table.getn(item) > 2 then -- minLevel is given for this item
                if playerLevel < item[3] then
                    meetsLevelLimit = false
                end
                if table.getn(item) > 3 then -- maxLevel is given for this item
                    if playerLevel > item[4] then
                        meetsLevelLimit = false
                    end
                end
            end
            if meetsLevelLimit then
                for amount = 1, itemProbability do
                    table.insert(temp_table, itemVnum)
                end
            end
        end
    )
    return temp_table[math.random(table.getn(temp_table))]
end

function get_time_remaining(seconds)
    if seconds <= 60 then
        return string.format(gameforge.locale.time.seconds, seconds)
    else
        local minutes = math.floor(seconds / 60)
        seconds = math.mod(seconds, 60)
        if minutes <= 60 then
            return string.format(gameforge.locale.time.minutes_and_seconds, minutes, seconds)
        else
            local hours = math.floor(minutes / 60)
            minutes = math.mod(minutes, 60)
            if hours <= 24 then
                return string.format(gameforge.locale.time.hours_and_minutes, hours, minutes)
            else
                local days = math.floor(hours / 24)
                hours = math.mod(hours, 24)
                return string.format(gameforge.locale.time.days_and_hours, days, hours)
            end
        end
    end
end

function count_item_range(firstVnum, lastVnum)
    local amount = 0
    for item = firstVnum, lastVnum, 1 do
        local i = pc.count_item(item)
        amount = amount + i
    end
    return amount
end

function remove_item_range(amountLeft, firstVnum, lastVnum)
    if count_item_range(firstVnum, lastVnum) < amountLeft then
        return false
    end
    for currentVnum = firstVnum, lastVnum, 1 do
        local currentAmount = pc.count_item(currentVnum)
        if currentAmount > 0 then
            if currentAmount < amountLeft then
                pc.remove_item(currentVnum, currentAmount)
                amountLeft = amountLeft - currentAmount
            else
                pc.remove_item(currentVnum, amountLeft)
                return true
            end
        end
    end
end

 -- is the player in the right map so we can place the questarrow?
 -- param maps is int define the maplookup table to search in
function is_destination_village(maps)
    local map_lookup = {}
    if maps == 1 then
        map_lookup = {[1]='', [21]='', [41]='' }
    elseif maps==2 then
        map_lookup = {[3]='', [23]='', [43]='' }
    elseif maps==3 then
        map_lookup = {[1]='', [21]='', [41]='',[3]='', [23]='', [43]='' }
    elseif maps==65 then
        map_lookup = {[65]='' }
    end
    return map_lookup[pc.get_map_index()]
end
function say_important_title(name) say(color256(255, 230, 186)..name..color256(196, 196, 196)) end
function say_important(name) say(color256(255, 230, 186)..name..color256(196, 196, 196)) end
 

 

quest:

Spoiler

quest dragon_lair_weekly begin
    state start begin

        function set_settings()
            local settings = { }
            -- how long the player has to wait until he can do the quest again
            settings.cooldown_time = 561600 -- 60 seconds * 60 minutes * 24 hours * 6.5 days
            -- how long the player has time to get the items
            settings.time_to_hunt = 7200 -- 2 hours
            
            -- those items should be hunted
            settings.items_to_hunt = {
                30198,
                30199,
                50721,
                50722,
                50723,
                50725,
                50726,
                50727
            }
            -- the amount of items to be hunted. Array field relate to settings.items_to_hunt
            settings.amount_to_hunt = {
                10,
                10,
                50,
                50,
                50,
                50,
                50,
                50
            }

            settings.amount_to_pay = 150000

            -- Rewards:
            -- how often he gets a normal item instead of a poly marble
            settings.normal_items_rate = 50 -- in percent

            -- reward tables follow the rules: {vnum, quantity, mininum level, maximum level}
            -- reward items when giving a normal item
            settings.normal_items = {
                {70008, 1}
            }

            -- vnum of the poly marble (to show an icon to the player)
            settings.poly_item_vnum = 71093

            -- mobs to give in a poly marble
            settings.poly_mobs = {
                {175, 6},
                {184, 6},
                {501, 4},
                {502, 4},
                {552, 2, 85},
                {771, 6},
                {1601, 2, 95},
                {2001, 4},
                {2051, 2, 90},
                {2061, 2, 90},
                {2131, 6},
                {5003, 6}
            }

            return settings
        end

        when login or enter or levelup with pc.get_level() >= 85 begin
            set_state(getquest)
        end
    end

    state getquest begin

        when enter begin
            pc.setqf("item_to_hunt", 0)
            pc.setqf("amount_to_hunt", 0)
        end

        -- "Give me polymorph items!"
        when 30122.chat.gameforge.dragon_lair_weekly._010_chat with pc.get_map_index() == 73 begin
            local settings = dragon_lair_weekly.set_settings()
            local time_to_wait = pc.getqf("lasttime") - get_global_time() + settings.cooldown_time
            -- "Ghost of a warrior: "
            say_title(gameforge.dragon_lair_weekly._020_sayTitle)
            say("")
            if time_to_wait < 0 then 
                -- the player has no cooldown any longer
                local item_to_hunt = pc.getqf("item_to_hunt")
                local amount_to_hunt = pc.getqf("amount_to_hunt")
                if item_to_hunt == 0 then
                    local table_number = math.random(table.getn(settings.items_to_hunt))
                    item_to_hunt = settings.items_to_hunt[table_number]
                    amount_to_hunt = settings.amount_to_hunt[table_number]
                    pc.setqf("item_to_hunt", item_to_hunt)
                    pc.setqf("amount_to_hunt", amount_to_hunt)
                end

                -- "You have to collect %s:"
                say(string.format(gameforge.dragon_lair_weekly._030_say, amount_to_hunt))
                say("")
                say_item_vnum(item_to_hunt)
                -- "Then I will give you polymorph!"
                say(gameforge.dragon_lair_weekly._040_say)
                say("")
                -- yes / no
                local accept = select(gameforge.dragon_lair_weekly._050_select, gameforge.dragon_lair_weekly._060_select)
                if accept == 1 then
                    set_state(hunt_item)
                else
                    say_title(gameforge.dragon_lair_weekly._020_sayTitle)
                    say("")
                    -- "You are mean to me!"
                    say(gameforge.dragon_lair_weekly._070_say)
                    say("")
                end
            else
                -- player still has cooldown
                -- "You have to wait %s longer!"
                say(string.format(gameforge.dragon_lair_weekly._080_say, get_time_remaining(time_to_wait)))
                say("")
            end
        end
    end

    state hunt_item begin

        -- returns the amount of items the player still has to hunt
        function get_amount_remaining()
            return (pc.getqf("amount_to_hunt") - pc.count_item(pc.getqf("item_to_hunt")))
        end

        -- returns the time in seconds the player has left collecting the items.
        function get_time_remaining()
            local settings = dragon_lair_weekly.set_settings()
            return (pc.getqf("lasttime") - get_global_time() + settings.time_to_hunt)
        end

        when login begin
            -- add a quest icon and timer
            local time_remaining = dragon_lair_weekly.get_time_remaining()
            q.set_clock(gameforge.dragon_lair_weekly._090_questRest, time_remaining) -- timer that will be shown to the player
            timer("dragon_lair_weekly_timer", time_remaining) -- timer that will trigger the failing of this quest 
            if dragon_lair_weekly.get_amount_remaining() > 0 then
                -- "Collect things!"
                send_letter(gameforge.dragon_lair_weekly._100_sendLetter)
                q.set_title(gameforge.dragon_lair_weekly._110_sayTitle)
            else
                -- "Things collected!"
                send_letter(gameforge.dragon_lair_weekly._120_sendLetter)
                q.set_title(gameforge.dragon_lair_weekly._130_sayTitle)
            end
            q.start()
        end

        when enter begin
            local settings = dragon_lair_weekly.set_settings()
            local time_remaining = settings.time_to_hunt
            pc.setqf("lasttime", get_global_time()) -- reset the cooldown
            -- "Collect things!"
            send_letter(gameforge.dragon_lair_weekly._100_sendLetter)
            q.set_title(gameforge.dragon_lair_weekly._110_sayTitle)
            q.set_clock(gameforge.dragon_lair_weekly._090_questRest, time_remaining) -- timer that will trigger the failing of this quest 
            timer("dragon_lair_weekly_timer", time_remaining) -- timer that will trigger the failing of this quest 
            q.start()
        end

        when info or button begin
            local settings = dragon_lair_weekly.set_settings()
            local amount_remaining = dragon_lair_weekly.get_amount_remaining()
            if (amount_remaining > 0) then
                local time_remaining = dragon_lair_weekly.get_time_remaining()
                if (time_remaining > 0) then
                    -- player still has to collect items
                    say_title(gameforge.dragon_lair_weekly._110_sayTitle) -- quest title
                    -- "You still have to collect %s:"
                    say("")
                    say(string.format(gameforge.dragon_lair_weekly._140_say, amount_remaining))
                    say("")
                    say_item_vnum(pc.getqf("item_to_hunt"))
                    say("")
                    say("")
                    say("")
                    say(gameforge.dragon_lair_weekly._090_questRest .. get_time_remaining(time_remaining))
                    say("")
                else
                    -- player did not collect the items in time
                    -- "You failed collecting the items in time!"
                    notice_multiline(gameforge.dragon_lair_weekly._160_notice,notice)
                    q.done()
                    set_state(getquest) -- reset the quest, but the cooldown remains
                end
            else
                say_title(gameforge.dragon_lair_weekly._130_sayTitle) -- quest title
                say("")
                -- "You have all needed items. Go back to the warrior Ghost! He is in heavens cave 2"
                say(gameforge.dragon_lair_weekly._150_say)
                say("")
            end
        end

        when dragon_lair_weekly_timer.timer begin
            -- the player did not collect the items in time
            -- "You failed collecting the items in time!"
            notice_multiline(gameforge.dragon_lair_weekly._160_notice,notice)
            q.done()
            set_state(getquest) -- reset the quest, but the cooldown remains
        end

        when 30122.chat.gameforge.dragon_lair_weekly._010_chat with pc.get_map_index() == 73 begin
            local settings = dragon_lair_weekly.set_settings()
            say_title(gameforge.dragon_lair_weekly._020_sayTitle)
            say("")
            local amount_remaining = dragon_lair_weekly.get_amount_remaining()
            if amount_remaining > 0 then
                -- the player did not collect enough items
                -- "You still have to collect %s:"
                say(string.format(gameforge.dragon_lair_weekly._140_say, amount_remaining))
                say("")
                say_item_vnum(pc.getqf("item_to_hunt"))
                say("")
                -- "Then I will give you polymorph!"
                say(gameforge.dragon_lair_weekly._040_say)
                say("")
            elseif pc.money < settings.amount_to_pay then
                -- you don't have enough yang to pay
                say(gameforge.dragon_lair_weekly._175_say)
                say("")
            else
                -- "You want to give me %s ?: "
                say(string.format(gameforge.dragon_lair_weekly._170_say, pc.getqf("amount_to_hunt")))
                say("")
                say_item_vnum(pc.getqf("item_to_hunt"))
                -- "Yes" / "No"
                local give_item = select(gameforge.dragon_lair_weekly._180_select, gameforge.dragon_lair_weekly._190_select)
                say("")
                say_title(gameforge.dragon_lair_weekly._020_sayTitle)
                say("")
                if (give_item == 1) then
                    -- "Thanks, now you get this from me: "
                    -- see if a normal item, or a polymorph item should be given
                    if math.random(100) < settings.normal_items_rate then -- normal item
                        say(gameforge.dragon_lair_weekly._205_sayReward)
                        say("")
                        local award_vnum = get_random_vnum_from_table(settings.normal_items)
                        say_item_vnum(award_vnum)
                        say("")
                        pc.give_item2(award_vnum)
                    else -- polymorph item
                        say(gameforge.dragon_lair_weekly._200_sayReward)
                        say("")
                        local award_vnum = get_random_vnum_from_table(settings.poly_mobs)
                        say_item(item_name(settings.poly_item_vnum), settings.poly_item_vnum, mob_name(award_vnum))
                        say("")
                        pc.give_poly_marble(award_vnum) -- give a poly morph item with this mob vnum in it
                    end

                    pc.remove_item(pc.getqf("item_to_hunt"), pc.getqf("amount_to_hunt")) -- remove the questitems from inventory
                    pc.changemoney(settings.amount_to_pay) -- player pays yang for the item
                    q.done()
                    set_state(getquest)
                else
                    say(gameforge.dragon_lair_weekly._210_say)
                    say("")
                end
            end
        end
    end
end
 

 

Agradeço a quem me poder me ajudar com esse erro.

 

Boa noite a todos...

Share this post


Link to post
Share on other sites

0 answers to this question

There have been no answers to this question yet