• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TASK SYSTEM --- reward lvl task -

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
342
Solutions
2
Reaction score
58
Hello, it's possible to have reward after task LVL. currently is exp

LUA:
[1] = {name = "Dragon", storage = 761000, monsters_list = {"Dragon"}, can_repeat = false, level_min = 10, count = 4, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},

I saw somethink like that:
add this in rewards table
{type = "lvl", value = {4}
Best Regards
 
Last edited:
@up Yea please :

LUA:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Automatic Simple Task" version="1.0" author="Vodkart" contact="tibiaking.com" enabled="yes">
<config name="auto_stask"><![CDATA[

automatic_task = {
[1] = {name = "Dragon", storage = 761000, monsters_list = {"Dragon"}, can_repeat = false, level_min = 10, count = 4, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[2] = {name = "Crystal Spider", storage = 761001, monsters_list = {"Crystal Spider"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[3] = {name = "Damaged Worker Golem", storage = 761002, monsters_list = {"Damaged Worker Golem"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[4] = {name = "Demon", storage = 761003, monsters_list = {"Demon"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[5] = {name = "Dragon Lord", storage = 761004, monsters_list = {"Dragon Lord"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[6] = {name = "Donate Gang Member", storage = 761005, monsters_list = {"Donate Gang Member"}, can_repeat = false, level_min = 10, count = 15000, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 73000000},
[7] = {name = "Earth Elemental", storage = 761006, monsters_list = {"Earth Elemental"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[8] = {name = "Eternal Guardian", storage = 761007, monsters_list = {"Eternal Guardian"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[9] = {name = "Ferumbras", storage = 761008, monsters_list = {"Ferumbras"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
[10] = {name = "Frost Dragon", storage = 761009, monsters_list = {"Frost Dragon"}, can_repeat = false, level_min = 10, count = 2500, reward = {{6527,75}, {2160,100}, {8261,1}, {10314,1}}, exp = 500000},
}

automatic_task_config = {
    reward_type = MESSAGE_STATUS_CONSOLE_BLUE,
    defeat_type = MESSAGE_STATUS_CONSOLE_ORANGE,
    defeat_storage = 963850,
    lvl_advance_control = 963851
}

function getItemsFromList(items)
    local str = ''
    if #items > 0 then
        for i = 1, #items do
            str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
            if i ~= #items then str = str .. ', ' end
        end
    end
    return str
end

function getMonsterFromList(monster)
    local str = ''
    if #monster > 0 then
        for i = 1, #monster do
            str = str .. monster[i]
            if i ~= #monster then str = str .. ', ' end
        end
    end
    return str
end

function GiveRewardsTask(cid, items)
    local backpack = doPlayerAddItem(cid, 7343, 1) -- backpackID
    for _, i_i in ipairs(items) do
        local item, amount = i_i[1], i_i[2]
        if isItemStackable(item) or amount == 1 then
            doAddContainerItem(backpack, item, amount)
        else
            for i = 1, amount do
                doAddContainerItem(backpack, item, 1)
            end
        end
    end
end

]]></config>
<event type="advance" name="TaskAutAdvance" event="script"><![CDATA[
domodlib('auto_stask')
function onAdvance(cid, skill, oldLevel, newLevel)
    if (skill == SKILL__LEVEL) then
        if getPlayerStorageValue(cid, automatic_task_config.lvl_advance_control) < newLevel then
            for k, v in pairs(automatic_task) do
                if v.level_min == newLevel then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Task Automatico] --> Voce Desbloqueou a "..v.name.." Task! Parabens!")
                end
            end
            setPlayerStorageValue(cid, automatic_task_config.lvl_advance_control, newLevel)
        end
    end
    return true
end
]]></event>
<talkaction words="/task;!task" event="buffer"><![CDATA[
domodlib('auto_stask')
param, str = param:lower(), "Task(s) Disponiveis:\n\n"
if isInArray({"counter","contador","count"}, param) then
    setPlayerStorageValue(cid, automatic_task_config.defeat_storage, getPlayerStorageValue(cid, automatic_task_config.defeat_storage) <= 0 and 1 or 0)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Task Automatico] --> O Contador Foi "..(getPlayerStorageValue(cid, automatic_task_config.defeat_storage) <= 0 and "Ativado" or "Desativado")..".")
    return true
end
for k, v in pairs(automatic_task) do
    if getPlayerLevel(cid) >= v.level_min and getPlayerStorageValue(cid, v.storage) < v.count then
        local amount = getPlayerStorageValue(cid, v.storage) <= 0 and 0 or getPlayerStorageValue(cid, v.storage)
        str = str.."[+] "..v.name.." Task [+]\n\nMonster Count: ["..amount.."/"..v.count.."]\n\nMonsters Killing: "..getMonsterFromList(v.monsters_list)..".\n\nLevel: "..v.level_min.." or More.\n\nCan repeat: "..(v.can_repeat and "yes" or "no")..".\n\nRewards: "..(#v.reward > 0 and getItemsFromList(v.reward) or "Nothing")..".\n\nExp: "..(v.exp > 0 and v.exp or 0)..".\n\n"
    end
end
return doShowTextDialog(cid, 8983, str)
]]></talkaction>
<event type="login" name="TaskAutLogin" event="script"><![CDATA[
function onLogin(cid)
    registerCreatureEvent(cid, "KillAutTask")
    registerCreatureEvent(cid, "TaskAutAdvance")
    return true
end
]]></event>
<event type="kill" name="KillAutTask" event="script"><![CDATA[
domodlib('auto_stask')
function onKill(cid, target)
    local str = ""
    if isPlayer(cid) and isMonster(target) then
        for task, info in pairs(automatic_task) do
            if isInArray(info.monsters_list, getCreatureName(target)) and getPlayerLevel(cid) >= info.level_min then
                local ret = getPlayerStorageValue(cid, info.storage) <= 0 and 0 or getPlayerStorageValue(cid, info.storage)
                if ret < info.count then
                    setPlayerStorageValue(cid, info.storage, getPlayerStorageValue(cid, info.storage) <= 0 and 1 or (getPlayerStorageValue(cid, info.storage)+1))
                    if getPlayerStorageValue(cid, automatic_task_config.defeat_storage) <= 0 and getPlayerStorageValue(cid, info.storage) < info.count then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Task Automatico] --> Voce Matou [" .. getPlayerStorageValue(cid, info.storage) .. "/" .. info.count .. "] da Task do " .. info.name .. ".")
                    end
                    if getPlayerStorageValue(cid, info.storage) >= info.count then
                        if info.exp > 0 then
                            doPlayerAddExp(cid, info.exp)
                            str = str..(str == "" and "" or ", ")..info.exp.." de Exp"
                        end
                        if #info.reward > 0 then
                            GiveRewardsTask(cid, info.reward)
                            str = str..(str == "" and "" or ", ")..getItemsFromList(info.reward)
                        end
                        doPlayerSendTextMessage(cid, automatic_task_config.reward_type, "[Task Automatico] --> Voce Completou a "..info.name.." Task. PREMIOS: "..(str == "" and "nenhuma" or str))
                        if info.can_repeat == true then
                            setPlayerStorageValue(cid, info.storage, 0)
                        end
                    end
                end
            end
        end
    end
    return true
end
]]></event>
</mod>

This is /data/MOD
 
just change this:
LUA:
if info.exp > 0 then
    doPlayerAddExp(cid, info.exp)
    str = str..(str == "" and "" or ", ")..info.exp.." de Exp"
end
to
LUA:
if info.exp > 0 then
    doPlayerAddExp(cid, info.exp)
    str = str..(str == "" and "" or ", ")..info.exp.." de Exp"
elseif info.level > 0 then
    doPlayerAddLevel(cid, info.level)
    str = str..(str == "" and "" or ", ")..info.level.." de Level"
end

I think that func existed back then, if not, you will need to calculate the exp needed from current level to the desired level and add it.
 
Yeah instead of:
LUA:
, exp = 500000},
You write:
LUA:
, level = 5},

and this will give you 5 levels.

Just to make sure, you want to give whole levels as a reward right?
 
LUA:
[17:48:25.728] [Error - CreatureScript Interface]
[17:48:25.728] domodlib('auto_stask')
[17:48:25.729] function onKill(cid, target)
[17:48:25.729]     local str = ""
[17:48:25.729]     if isPlayer(cid) and isMonster(target) then
[17:48:25.729]         for task, info in pairs(automatic_task) do
[17:48:25.729]             if isInArray(info.monsters_list, getCreatureName(target)) and getPlayerLevel(cid) >= info.level_min then
[17:48:25.730]                 local ret = getPlayerStorageValue(cid, info.storage) <= 0 and 0 or getPlayerStorageValue(cid, info.storage)
[17:48:25.730]                 if ret < info.count then
[17:48:25.730]                     setPlayerStorageValue(cid, info.storage, getPlayerStorageValue(cid, info.storage) <= 0 and 1 or (getPlayerStorageValue(cid, info.storage)+1))
[17:48:25.730]                     if getPlayerStorageValue(cid, automatic_task_config.defeat_storage) <= 0 and getPlayerStorageValue(cid, info.storage) < info.count then
[17:48:25.730]                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Task Automatico] --> Voce Matou [" .. getPlayerStorageValue(cid, info.storage) .. "/" .. info.count .. "] da Task do " .. info.name .. ".")
[17:48:25.730]                     end
[17:48:25.730]                     if getPlayerStorageValue(cid, info.storage) >= info.count then
[17:48:25.731]  if info.exp > 0 then
[17:48:25.731]     doPlayerAddExp(cid, info.exp)
[17:48:25.731]     str = str..(str == "" and "" or ", ")..info.exp.." de Exp"
[17:48:25.731] elseif info.level > 0 then
[17:48:25.731]     doPlayerAddLevel(cid, info.level)
[17:48:25.731]     str = str..(str == "" and "" or ", ")..info.level.." de Level"
[17:48:25.731] end
[17:48:25.732]                         if #info.reward > 0 then
[17:48:25.732]                             GiveRewardsTask(cid, info.reward)
[17:48:25.732]                             str = str..(str == "" and "" or ", ")..getItemsFromList(info.reward)
[17:48:25.732]                         end
[17:48:25.732]                         doPlayerSendTextMessage(cid, automatic_task_config.reward_type, "[Task Automatico] --> Voce Completou a "..info.name.." Task. PREMIOS: "..(str == "" and "nenhuma" or str))
[17:48:25.732]                         if info.can_repeat == true then
[17:48:25.732]                             setPlayerStorageValue(cid, info.storage, 0)
[17:48:25.733]                         end
[17:48:25.733]                     end
[17:48:25.733]                 end
[17:48:25.733]             end
[17:48:25.733]         end
[17:48:25.733]     end
[17:48:25.733]     return true
[17:48:25.734] end
[17:48:25.734] :onKill
[17:48:25.734] Description:
[17:48:25.734] [string "LuaInterface::loadBuffer"]:14: attempt to compare number with nil
[17:48:25.734] stack traceback:
[17:48:25.734]  [string "LuaInterface::loadBuffer"]:14: in function <[string "LuaInterface::loadBuffer"]:2>

I use mod
 
LUA:
if info.exp and info.exp > 0 then
    doPlayerAddExp(cid, info.exp)
    str = str..(str == "" and "" or ", ")..info.exp.." de Exp"
elseif info.level and info.level > 0 then
    doPlayerAddLevel(cid, info.level)
    str = str..(str == "" and "" or ", ")..info.level.." de Level"
end
 
Back
Top