• 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 data/actions/scripts/quests/quests.lua:4: attempt to index local 'value' (a nil value)

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
Why my quests is not working?

It is showing this error on console:
error on console:
Code:
[20:0:29.635] [Error - Action Interface] 
[20:0:29.635] data/actions/scripts/quests/quests.lua:onUse
[20:0:29.635] Description: 
[20:0:29.635] data/actions/scripts/quests/quests.lua:4: attempt to index local 'value' (a nil value)
[20:0:29.635] stack traceback:
[20:0:29.635]     data/actions/scripts/quests/quests.lua:4: in function 'isLevelRequired'
[20:0:29.635]     data/actions/scripts/quests/quests.lua:7: in function <data/actions/scripts/quests/quests.lua:6>


data/actions/scripts/quests/quests.lua:
Code:
dofile(getDataDir() .. "actions/scripts/quests/quests_list.lua")

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(zexus_quest_list[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 = zexus_quest_list[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



data/actions/scripts/quests/quests_list.lua:

Code:
mins = 60
hours = 60 * 60
days = 24 * 60 * 60

zexus_quest_list = {
    -- 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 Rookx", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours}
}
Post automatically merged:

why its printing the ids, but not the other stuff?

Code:
dofile(getDataDir() .. "actions/scripts/quests/quests_list.lua")

function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    print("quest action:")
    print(zexus_quest_list)
    for q, quest in pairs(zexus_quest_list) do
        print(q)
    end
    -- local levelRequired, quest, level = isLevelRequired(zexus_quest_list[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 = zexus_quest_list[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

console:
Code:
quest action:

8003
8005
8000
8002
8004
8001
 
Last edited:
Solution
I'm using because it was in the main script...
Now its working, on the first click, when get the item
But when the quest in on exausted (when i try again)

Shows this:

Code:
[13:28:43.142] [Error - Action Interface]
[13:28:43.142] data/actions/scripts/quests/quests.lua:onUse
[13:28:43.142] Description:
[13:28:43.142] data/actions/scripts/quests/quests.lua:24: attempt to compare nil with number
[13:28:43.142] stack traceback:
[13:28:43.142]     data/actions/scripts/quests/quests.lua:24: in function <data/actions/scripts/quests/quests.lua:1>
inside of lib, get rid of 'local' on hours/mins/days.

And here's a slightly modified script to use..
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local quest =...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
I still don't understand why you refuse to use the lib folder for your table.

Just literally copy-paste your table into data/lib/000-constant.lua
Remove the dofile stuff

and all your problems will be fixed.
Post automatically merged:

and/or do teamviewer / discord call with me. I'll send you my details in pm
This is such a simple fix. We shouldn't have 3 separate threads for the same issue over a 6 month period to resolve this.
 
Last edited:
OP
OP
zexus

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
I still don't understand why you refuse to use the lib folder for your table.

Just literally copy-paste your table into data/lib/000-constant.lua
Remove the dofile stuff

and all your problems will be fixed.
Post automatically merged:

and/or do teamviewer / discord call with me. I'll send you my details in pm
This is such a simple fix. We shouldn't have 3 separate threads for the same issue over a 6 month period to resolve this.

I saw in other topic that i couldn't use objects table in lib
I did not know i could

---

The other topic was about quest talkaction
And this talkaction is working fine:
Code:
dofile(getDataDir() .. "actions/scripts/quests/quests_list.lua")

function onSay(cid, words, param, channel)
    print("quest talkaction:")
    print(zexus_quest_list)
    for q, quest in pairs(zexus_quest_list) do
        print(q)
    end
    local time = os.time()
    local final = ''
    -- We are looping from 8000 to 8005, so those are the storages that we will check.
    for q, quest in pairs(zexus_quest_list) do
        local storage = quest -- In this local we get the information, for example if q is equal to 8000 and you print storage.name you will get "Sabre Rook".
        local str = ''


        local continue = false
        -- don't show everything, only exausted one, cause there are a lot of quests
        if getPlayerStorageValue(cid, q) < 0 then
            -- str = 'You have never done '..storage.name..' quest! Time to get to it.'
            continue = true
        elseif time - getPlayerStorageValue(cid, q) >= 0 then
            -- str = 'You can now do '..storage.name..' quest again!'
            continue = true
        end

        if not continue then
            if getPlayerStorageValue(cid, q) - time > days then
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / days) ..' days to do the '..storage.name..' quest again.'
            elseif getPlayerStorageValue(cid, q) - time > hours then
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / hours) ..' hours to do the '..storage.name..' quest again.'
            else
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / mins) ..' minutes to do the '..storage.name..' quest again.'
            end
            final = final .. "[" .. storage.name .. "]: " .. str .. "\n\n"
        end
    end
    doShowTextDialog(cid, 2175, final)
    return true
end

This now is about the action (to click on chest and recive the items)

I tried what u said
Code:
...


global_equip_exhaust = {}

xikini_quest_list = {
    -- 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 Rookx", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours}
}

with
Code:
function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    print("quest action:")
    print(xikini_quest_list)
    for q, quest in pairs(xikini_quest_list) do
        print(q)
    end
    local levelRequired, quest, level = isLevelRequired(xikini_quest_list[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 mins = 60
        local hours = 60 * 60
        local days = 24 * 60 * 60
        local storage = 200000 + item.actionid
        local quest = xikini_quest_list[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


and my server stops to open in:
Code:
[12:39:54.431] The Forgotten Server 0.4

[12:39:54.431] >> Loading config (config.lua)
[12:39:54.453] >> Opening logs

>> Loading Demon Oak Lib V0.70 REV: 1 (June 26 2012) By Darkhaos (Contact: http://otland.net/members/darkhaos/)

[!] -> Checking demon oak lib...
[!] -> 0 problems loaded in 0.000265 seconds.

[!] -> Demon Oak Lib loaded in 0.00129 seconds.

[12:39:54.602] >> Opening logs

^C
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
I saw in other topic that i couldn't use objects table in lib
I did not know i could

---

The other topic was about quest talkaction
And this talkaction is working fine:
Code:
dofile(getDataDir() .. "actions/scripts/quests/quests_list.lua")

function onSay(cid, words, param, channel)
    print("quest talkaction:")
    print(zexus_quest_list)
    for q, quest in pairs(zexus_quest_list) do
        print(q)
    end
    local time = os.time()
    local final = ''
    -- We are looping from 8000 to 8005, so those are the storages that we will check.
    for q, quest in pairs(zexus_quest_list) do
        local storage = quest -- In this local we get the information, for example if q is equal to 8000 and you print storage.name you will get "Sabre Rook".
        local str = ''


        local continue = false
        -- don't show everything, only exausted one, cause there are a lot of quests
        if getPlayerStorageValue(cid, q) < 0 then
            -- str = 'You have never done '..storage.name..' quest! Time to get to it.'
            continue = true
        elseif time - getPlayerStorageValue(cid, q) >= 0 then
            -- str = 'You can now do '..storage.name..' quest again!'
            continue = true
        end

        if not continue then
            if getPlayerStorageValue(cid, q) - time > days then
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / days) ..' days to do the '..storage.name..' quest again.'
            elseif getPlayerStorageValue(cid, q) - time > hours then
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / hours) ..' hours to do the '..storage.name..' quest again.'
            else
                str = 'You must wait '.. math.ceil(((getPlayerStorageValue(cid, q)) - time) / mins) ..' minutes to do the '..storage.name..' quest again.'
            end
            final = final .. "[" .. storage.name .. "]: " .. str .. "\n\n"
        end
    end
    doShowTextDialog(cid, 2175, final)
    return true
end

This now is about the action (to click on chest and recive the items)

I tried what u said
Code:
...


global_equip_exhaust = {}

xikini_quest_list = {
    -- 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 Rookx", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours}
}

with
Code:
function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    print("quest action:")
    print(xikini_quest_list)
    for q, quest in pairs(xikini_quest_list) do
        print(q)
    end
    local levelRequired, quest, level = isLevelRequired(xikini_quest_list[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 mins = 60
        local hours = 60 * 60
        local days = 24 * 60 * 60
        local storage = 200000 + item.actionid
        local quest = xikini_quest_list[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


and my server stops to open in:
Code:
[12:39:54.431] The Forgotten Server 0.4

[12:39:54.431] >> Loading config (config.lua)
[12:39:54.453] >> Opening logs

>> Loading Demon Oak Lib V0.70 REV: 1 (June 26 2012) By Darkhaos (Contact: http://otland.net/members/darkhaos/)

[!] -> Checking demon oak lib...
[!] -> 0 problems loaded in 0.000265 seconds.

[!] -> Demon Oak Lib loaded in 0.00129 seconds.

[12:39:54.602] >> Opening logs

^C
Because you never declared mins/hours/days..

Add those as well or change the table.

Lua:
xikini_quest_list = {
    -- rook
    [8000] = { name = "Sabre Rook", item = 2385, lvl = 1, time = 900},
    [8001] = { name = "Doublet Rook", item = 2485, lvl = 2, time = 1800},
    [8002] = { name = "Studded Shield Rook", item = 2526, lvl = 3, time = 3000},
    [8003] = { name = "Copper Shield Rook", item = 2530, lvl = 5, time = 10800},
    [8004] = { name = "Legion Helmet Rookx", item = 2480, lvl = 5, time = 18000},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 36000}
}
 
OP
OP
zexus

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
Because you never declared mins/hours/days..

Add those as well or change the table.

Lua:
xikini_quest_list = {
    -- rook
    [8000] = { name = "Sabre Rook", item = 2385, lvl = 1, time = 900},
    [8001] = { name = "Doublet Rook", item = 2485, lvl = 2, time = 1800},
    [8002] = { name = "Studded Shield Rook", item = 2526, lvl = 3, time = 3000},
    [8003] = { name = "Copper Shield Rook", item = 2530, lvl = 5, time = 10800},
    [8004] = { name = "Legion Helmet Rookx", item = 2480, lvl = 5, time = 18000},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 36000}
}

You are rigth!
Now its open, but with errors

lib
Code:
local mins = 60
local hours = 60 * 60
local days = 24 * 60 * 60
xikini_quest_list = {
    -- 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 Rookx", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours}
}

action
Code:
function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    print("quest action:")
    print(xikini_quest_list)
    for q, quest in pairs(xikini_quest_list) do
        print(q)
    end
    local levelRequired, quest, level = isLevelRequired(xikini_quest_list[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 mins = 60
        local hours = 60 * 60
        local days = 24 * 60 * 60
        local storage = 200000 + item.actionid
        local quest = xikini_quest_list[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

errors:
Code:
[13:9:38.839] [Error - Action Interface]
[13:9:38.839] data/actions/scripts/quests/quests.lua:onUse
[13:9:38.839] Description:
[13:9:38.839] data/actions/scripts/quests/quests.lua:2: attempt to index local 'value' (a nil value)
[13:9:38.839] stack traceback:
[13:9:38.839]     data/actions/scripts/quests/quests.lua:2: in function 'isLevelRequired'
[13:9:38.839]     data/actions/scripts/quests/quests.lua:10: in function <data/actions/scripts/quests/quests.lua:4>


This isLevelRequired has 3 returns?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
You are rigth!
Now its open, but with errors

lib
Code:
local mins = 60
local hours = 60 * 60
local days = 24 * 60 * 60
xikini_quest_list = {
    -- 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 Rookx", item = 2480, lvl = 5, time = 5 * hours},
    [8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours}
}

action
Code:
function isLevelRequired(value)
    return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
    print("quest action:")
    print(xikini_quest_list)
    for q, quest in pairs(xikini_quest_list) do
        print(q)
    end
    local levelRequired, quest, level = isLevelRequired(xikini_quest_list[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 mins = 60
        local hours = 60 * 60
        local days = 24 * 60 * 60
        local storage = 200000 + item.actionid
        local quest = xikini_quest_list[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

errors:
Code:
[13:9:38.839] [Error - Action Interface]
[13:9:38.839] data/actions/scripts/quests/quests.lua:onUse
[13:9:38.839] Description:
[13:9:38.839] data/actions/scripts/quests/quests.lua:2: attempt to index local 'value' (a nil value)
[13:9:38.839] stack traceback:
[13:9:38.839]     data/actions/scripts/quests/quests.lua:2: in function 'isLevelRequired'
[13:9:38.839]     data/actions/scripts/quests/quests.lua:10: in function <data/actions/scripts/quests/quests.lua:4>


This isLevelRequired has 3 returns?
Why are you even using that function..?
It's literally pointless.

try.. this I guess.
Lua:
function onUse(cid, item, fromPos, item2, toPos)
    local quest = xikini_quest_list[item.actionid]
    if not quest then
        doPlayerSendCancel(cid, "Item actionid not found in table. Contact GM")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    if quest.lvl and getPlayerLevel(cid) < quest.lvl then
        doPlayerSendCancel(cid, "Sorry, level: " .. level .. " or higher to complete this quest.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    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    
    return true
end
 
OP
OP
zexus

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
Why are you even using that function..?
It's literally pointless.

try.. this I guess.
Lua:
function onUse(cid, item, fromPos, item2, toPos)
    local quest = xikini_quest_list[item.actionid]
    if not quest then
        doPlayerSendCancel(cid, "Item actionid not found in table. Contact GM")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    if quest.lvl and getPlayerLevel(cid) < quest.lvl then
        doPlayerSendCancel(cid, "Sorry, level: " .. level .. " or higher to complete this quest.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    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   
    return true
end

I'm using because it was in the main script...
Now its working, on the first click, when get the item
But when the quest in on exausted (when i try again)

Shows this:

Code:
[13:28:43.142] [Error - Action Interface] 
[13:28:43.142] data/actions/scripts/quests/quests.lua:onUse
[13:28:43.142] Description: 
[13:28:43.142] data/actions/scripts/quests/quests.lua:24: attempt to compare nil with number
[13:28:43.142] stack traceback:
[13:28:43.142]     data/actions/scripts/quests/quests.lua:24: in function <data/actions/scripts/quests/quests.lua:1>
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,731
I'm using because it was in the main script...
Now its working, on the first click, when get the item
But when the quest in on exausted (when i try again)

Shows this:

Code:
[13:28:43.142] [Error - Action Interface]
[13:28:43.142] data/actions/scripts/quests/quests.lua:onUse
[13:28:43.142] Description:
[13:28:43.142] data/actions/scripts/quests/quests.lua:24: attempt to compare nil with number
[13:28:43.142] stack traceback:
[13:28:43.142]     data/actions/scripts/quests/quests.lua:24: in function <data/actions/scripts/quests/quests.lua:1>
inside of lib, get rid of 'local' on hours/mins/days.

And here's a slightly modified script to use..
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local quest = xikini_quest_list[item.actionid]
    if not quest then
        doPlayerSendCancel(cid, "Item actionid not found in table. Contact GM")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    if quest.lvl and getPlayerLevel(cid) < quest.lvl then
        doPlayerSendCancel(cid, "Sorry, level: " .. quest.lvl .. " or higher to complete this quest.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    local timeNow = os.time()
    local storage = getPlayerStorageValue(cid, item.actionid)
    if timeNow - storage >= 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 storage < 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
    elseif storage - timeNow > days then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/days) ..' days to do it again.')
    elseif storage - timeNow > hours then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/hours) ..' hours to do it again.')
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/mins) ..' minutes to do it again.')
    end   
    return true
end
 
Solution
OP
OP
zexus

zexus

Member
Joined
Oct 1, 2016
Messages
133
Reaction score
18
inside of lib, get rid of 'local' on hours/mins/days.

And here's a slightly modified script to use..
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local quest = xikini_quest_list[item.actionid]
    if not quest then
        doPlayerSendCancel(cid, "Item actionid not found in table. Contact GM")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    if quest.lvl and getPlayerLevel(cid) < quest.lvl then
        doPlayerSendCancel(cid, "Sorry, level: " .. quest.lvl .. " or higher to complete this quest.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return true
    end
    local timeNow = os.time()
    local storage = getPlayerStorageValue(cid, item.actionid)
    if timeNow - storage >= 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 storage < 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
    elseif storage - timeNow > days then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/days) ..' days to do it again.')
    elseif storage - timeNow > hours then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/hours) ..' hours to do it again.')
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil((storage - timeNow)/mins) ..' minutes to do it again.')
    end  
    return true
end

Ty u so much man
 
Top