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

Lua TFS 0.3.6 PROBLEM WITH SCRIPT TASK SYSTEM

samuel157

Intermediate OT User
Joined
Mar 19, 2010
Messages
616
Solutions
4
Reaction score
122
Location
São Paulo, Brazil
GitHub
Samuel10M
Code:
<?xml version="1.0" encoding="UTF-8"?> 
<mod name="Blessed Task" version="3.0" author="Vodkart" contact="xtibia.com" enabled="yes"> 
<config name="task_func_rgb"><![CDATA[

tasktabble = {
    ["asuras"] = {monster_race={"asuras"}, storage_start = 200284, storage = 91084, count = 717217, exp = 100000000000000, money = 100000000000},
    ["bashmus"] = {monster_race={"bashmus"}, storage_start = 200285, storage = 91085, count = 717217, exp = 100000000000000, money = 100000000000},
    ["carnivors"] = {monster_race={"carnivors"}, storage_start = 200286, storage = 91086, count = 717217, exp = 100000000000000, money = 100000000000},
["deathlings"] = {monster_race={"deathlings"}, storage_start = 200287, storage = 91087, count = 717217, exp = 100000000000000, money = 100000000000},
    ["dreamelves"] = {monster_race={"dreamelves"}, storage_start = 200288, storage = 91088, count = 717217, exp = 100000000000000, money = 100000000000},
    ["forest monsters"] = {monster_race={"forest monsters"}, storage_start = 200289, storage = 91089, count = 717217, exp = 100000000000000, money = 100000000000},
    ["lost souls"] = {monster_race={"lost souls"}, storage_start = 200290, storage = 91090, count = 717217, exp = 100000000000000, money = 100000000000},
    ["underwaters"] = {monster_race={"underwaters"}, storage_start = 200291, storage = 91091, count = 717217, exp = 100000000000000, money = 100000000000},
    ["goannas"] = {monster_race={"goannas"}, storage_start = 200292, storage = 91092, count = 717217, exp = 100000000000000, money = 100000000000},
    ["iksupans"] = {monster_race={"iksupans"}, storage_start = 200293, storage = 91093, count = 717217, exp = 100000000000000, money = 100000000000},
    ["ingols"] = {monster_race={"ingols"}, storage_start = 200294, storage = 91094, count = 717217, exp = 100000000000000, money = 100000000000},
    ["mercurial menace"] = {monster_race={"mercurial menace"}, storage_start = 200295, storage = 91095, count = 717217, exp = 1000000000000000, money = 100000000000},
    ["nagas"] = {monster_race={"nagas"}, storage_start = 200296, storage = 91096, count = 717217, exp = 100000000000000, money = 100000000000},
    ["savants"] = {monster_race={"savants"}, storage_start = 200297, storage = 91097, count = 717217, exp = 100000000000000, money = 100000000000},
    ["spectres"] = {monster_race={"spectres"}, storage_start = 200298, storage = 91098, count = 717217, exp = 100000000000000, money = 100000000000},
    ["wingeds"] = {monster_race={"wingeds"}, storage_start = 200299, storage = 91099, count = 717217, exp = 100000000000000, money = 100000000000},
}

configbosses_task = {
{race = "minotaur",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},
{race = "necromancer",Playerpos = {x = 196, y = 39, z = 7}, FromPosToPos = {{x = 195, y = 37, z = 7},{x = 198, y = 41, z = 7}}, time = 5},
{race = "dragon",Playerpos = {x = 208, y = 59, z = 7}, FromPosToPos = {{x = 206, y = 56, z = 7},{x = 209, y = 65, z = 7}}, time = 5}
}

function CheckTask(cid)
for k, v in pairs(tasktabble) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end
end
return false
end
function finisheAllTask(cid)
local config = {
exp = {true,1000},
money = {true,200000},
items ={false,{{2124,2},{2173,1}}},
premium ={true,5}
}
local x = true
for k, v in pairs(tasktabble) do
if tonumber(getPlayerStorageValue(cid,v.storage)) then
x = false
end
end
if x == true then
setPlayerStorageValue(cid, 258456, 0)
local b = getGlobalStorageValue(66666) if b == -1 then b = 1 end
if b < 11 then
setGlobalStorageValue(66666,b+1)
doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')
doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)
doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)
doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)
if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end
doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")
end
end
end
function HavePlayerPosition(cid, from, to)
    return isInRange(getPlayerPosition(cid), from, to) and true or false
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doAddItemsFromList(cid,items) -- by vodka
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
local count = items[i][2]
while count > 0 do
if isItemStackable(items[i][1]) then
doPlayerAddItemStacking(cid, items[i][1], 1)
else
doPlayerAddItem(cid, items[i][1],1)
end
count = count - 1
end
end
end
end
        function pairsByKeys(t, f)
          local a = {}
          for n in pairs(t) do table.insert(a, n) end
          table.sort(a, f)
          local i = 0
          local iter = function ()
                i = i + 1
                if a[i] == nil then return nil
                else return a[i], t[a[i]]
                end
          end
          return iter
        end
]]></config>
<event type="login" name="TaskLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "KillTask")
return true
end]]></event>
<talkaction words="!taskrgb" event="buffer"><![CDATA[
domodlib('task_func_rgb')
local param = string.lower(param)
if param == "rank" then
getRankStorage(cid, 258456, 20, "Task Rank Finalizadas") return true
end
local str = ""
str = str .. "-=[Task Completed]=-\n\n"
for k, v in pairsByKeys(tasktabble) do
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
str = str..k.." = ".. (not tonumber(contagem) and "["..contagem.."]" or "["..((contagem)-1).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)
]]></talkaction>   
<event type="kill" name="KillTask" event="script"><![CDATA[
domodlib('task_func_rgb')
function onKill(cid, target, lastHit)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>

















LUA:
domodlib('task_func_rgb')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if isInArray({"task","tasks","missao","mission"}, msg) then
npcHandler:say("Me diga o nome do monstro que você deseja fazer a task!", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tasktabble[msg] then
if CheckTask(cid) ~= true then
local contagem = getPlayerStorageValue(cid, tasktabble[msg].storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('Desculpe, mas você já terminou a task do '..msg, cid) return true end
setPlayerStorageValue(cid, tasktabble[msg].storage_start, 1)
npcHandler:say("Parabéns, agora você está participando da missão task do "..msg..", falta matar "..string.sub(((contagem)-1)-tasktabble[msg].count, 2).." "..msg, cid)
talkState[talkUser] = 0
else
npcHandler:say('Desculpe, mas você já faz parte de uma task!', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('digite o nome correto da missão task! para mais informações digite {!taskrgb}', cid)
talkState[talkUser] = 1
end
elseif isInArray({"receber","reward","recompensa","report","reportar"}, msg) then
if CheckTask(cid) then
for k, v in pairs(tasktabble) do
racetype = k
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('você só pode receber os items uma única vez!', cid) return true end
if (((contagem)-1) >= v.count) then
for _, check in pairs(configbosses_task) do
if string.lower(check.race) == string.lower(racetype) then
local on = getPlayersOnline()
for i=1, #on do
if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
selfSay('aguarde alguns instantes, tem pessoas fazendo a task.', cid) return true
end
end
doTeleportThing(cid, check.Playerpos)
local function checkArea(cid)
if not isCreature(cid) then return LUA_ERROR end
if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
addEvent(checkArea, check.time*60*1000, cid)
end
end
local str = ""
if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." de exp" end
if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." gps" end
if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end
npcHandler:say("Obrigado pela sua ajuda Recompensas: "..(str == "" and "nenhuma" or ""..str.."").." por ter completado a task do "..k, cid)
setPlayerStorageValue(cid, v.storage, "Finished")
setPlayerStorageValue(cid, v.storage_start, 0)
setPlayerStorageValue(cid, 258456, getPlayerStorageValue(cid, 258456) == -1 and 1 or getPlayerStorageValue(cid, 258456)+1)
finisheAllTask(cid)
else
npcHandler:say('Desculpe,mas você só matou '..((contagem)-1)..' de '..v.count..' '..k, cid)
end
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif isInArray({"sair","leave","exit"}, msg) then
if CheckTask(cid) then
talkState[talkUser] = 2
for k, v in pairs(tasktabble) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
storagesair = v.storage_start
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
npcHandler:say('você está participando de uma missão task do '..k..' e já tem '..((contagem)-1)..' '..k..' mortos, deseja mesmo sair?', cid)
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
setPlayerStorageValue(cid, storagesair, 0)
npcHandler:say("Você foi retirado da task com sucesso!", cid)
elseif msg == "no" then 
selfSay("Tudo bem então", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
You've been a member since 2010 and you still don't know how to format a script properly? Are there any errors?
I'll tell you how to fix that.... throw it in recycle bin and upgrade to 1.6.
 
help say npc hi asuras send this message
02:01 Blessed Tasks: Me diga o nome do monstro que você deseja fazer a task!
02:01 ADM [18173: asuras
02:01 Blessed Tasks: digite o nome correto da missão task! para mais informações digite !taskrgb
 
LUA:
if tasktabble[msg] then
This is false, which leads to the NPC saying the last message.
So you need to figure out if your lib data is actually being loaded
 
they are

There are two NPC tasks with the same code, but the first one works and the second one doesn't. When I type !task, the task screen for the creature with the second code appears.

Screenshot_2.webp
Screenshot_1.webp
SIMPLE TASK

LUA:
<?xml version="1.0" encoding="UTF-8"?> 
<mod name="Simple Task" version="3.0" author="Vodkart" contact="xtibia.com" enabled="yes"> 
<config name="task_func"><![CDATA[

tasktabble = {
    ["frost dragon"] = {monster_race={"frost dragon"}, storage_start = 200201, storage = 91001, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["demon"] = {monster_race={"demon"}, storage_start = 200202, storage = 91002, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["verminor"] = {monster_race={"verminor"}, storage_start = 200203, storage = 91003, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["bandit"] = {monster_race={"bandit"}, storage_start = 200204, storage = 91004, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc leader"] = {monster_race={"orc leader"}, storage_start = 200205, storage = 91005, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc berserker"] = {monster_race={"orc berserker"}, storage_start = 200206, storage = 91006, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc warrior"] = {monster_race={"orc warrior"}, storage_start = 200207, storage = 91007, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc warlord"] = {monster_race={"orc warlord"}, storage_start = 200208, storage = 91008, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc shaman"] = {monster_race={"orc shaman"}, storage_start = 200209, storage = 91009, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hero"] = {monster_race={"hero"}, storage_start = 200210, storage = 91010, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orc rider"] = {monster_race={"orc rider"}, storage_start = 200211, storage = 91011, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hydra"] = {monster_race={"hydra"}, storage_start = 200212, storage = 91012, count = 1000000, exp = 1000000000000000, money = 100000000000},
    ["vampire"] = {monster_race={"vampire"}, storage_start = 200213, storage = 91013, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["warlock"] = {monster_race={"warlock"}, storage_start = 200214, storage = 91014, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["battlemaster zunzu"] = {monster_race={"battlemaster zunzu"}, storage_start = 200215, storage = 91015, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["behemoth"] = {monster_race={"behemoth"}, storage_start = 200216, storage = 91016, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["grim reaper"] = {monster_race={"grim reaper"}, storage_start = 200217, storage = 91017, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["insect swarm"] = {monster_race={"insect swarm"}, storage_start = 200218, storage = 91018, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["ghastly dragon"] = {monster_race={"ghastly dragon"}, storage_start = 200219, storage = 91019, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["lizard chosen"] = {monster_race={"lizard chosen"}, storage_start = 200220, storage = 91020, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["gnarlhound"] = {monster_race={"gnarlhound"}, storage_start = 200221, storage = 91021, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["draken warmaster"] = {monster_race={"draken warmaster"}, storage_start = 200222, storage = 91022, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["draken spellweaver"] = {monster_race={"draken spellweaver"}, storage_start = 200223, storage = 91023, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["giant spider"] = {monster_race={"giant spider"}, storage_start = 200224, storage = 91024, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["medusa"] = {monster_race={"medusa"}, storage_start = 200225, storage = 91025, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hellgorak"] = {monster_race={"hellgorak"}, storage_start = 200226, storage = 91026, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dragon"] = {monster_race={"dragon"}, storage_start = 200227, storage = 91027, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["fada"] = {monster_race={"fada"}, storage_start = 200228, storage = 91028, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["demon vip"] = {monster_race={"demon vip","demon master vip"}, storage_start = 200229, storage = 91029, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["grim reaper vip"] = {monster_race={"grim reaper vip","grim reaper"}, storage_start = 200230, storage = 91030, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["frost dragon vip"] = {monster_race={"frost dragon vip","frost dragon"}, storage_start = 200231, storage = 91031, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hacker"] = {monster_race={"hacker"}, storage_start = 200232, storage = 91032, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["tibia bug"] = {monster_race={"tibia bug"}, storage_start = 200233, storage = 91033, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["abominator"] = {monster_race={"abominator"}, storage_start = 200234, storage = 91034, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dark abominator"] = {monster_race={"dark abominator"}, storage_start = 200235, storage = 91035, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["ushuriel"] = {monster_race={"ushuriel"}, storage_start = 200236, storage = 91036, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["amoeba"] = {monster_race={"amoeba"}, storage_start = 200237, storage = 91037, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dragao esqueleto"] = {monster_race={"bones", "dragao esqueleto"}, storage_start = 200238, storage = 91038, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["infernatil"] = {monster_race={"infernatil"}, storage_start = 200239, storage = 91039, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["morgaroth"] = {monster_race={"morgaroth"}, storage_start = 200240, storage = 91040, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["warlock vip"] = {monster_race={"warlock vip","warlock"}, storage_start = 200241, storage = 91041, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["medusa vip"] = {monster_race={"medusa vip","medusa"}, storage_start = 200242, storage = 91042, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hydra vip"] = {monster_race={"hydra","hydra vip"}, storage_start = 200243, storage = 91043, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["webster"] = {monster_race={"webster"}, storage_start = 200244, storage = 91044, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["the fire elemental"] = {monster_race={"the fire elemental"}, storage_start = 200245, storage = 91045, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["ghoul"] = {monster_race={"ghoul"}, storage_start = 200246, storage = 91046, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["demon skeleton"] = {monster_race={"demon skeleton"}, storage_start = 200247, storage = 91047, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["quara abominator"] = {monster_race={"quara abominator"}, storage_start = 200248, storage = 91048, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dwarf"] = {monster_race={"dwarf"}, storage_start = 200249, storage = 91049, count = 1000000, exp = 100000000000000, money = 500000},
    ["dwarf soldier"] = {monster_race={"dwarf soldier"}, storage_start = 200250, storage = 91050, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dwarf guard"] = {monster_race={"dwarf guard"}, storage_start = 200251, storage = 91051, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["the spirit"] = {monster_race={"the spirit"}, storage_start = 200252, storage = 91052, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["lobisomen"] = {monster_race={"lobisomen"}, storage_start = 200253, storage = 91053, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orchid frog"] = {monster_race={"orchid frog","coral frog","crimson frog","azure frog"}, storage_start = 200254, storage = 91054, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["achad"] = {monster_race={"achad"}, storage_start = 200255, storage = 91055, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["yakchal"] = {monster_race={"yakchal"}, storage_start = 200256, storage = 91056, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["the masked marauder"] = {monster_race={"the masked marauder"}, storage_start = 200257, storage = 91057, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["zoralurk"] = {monster_race={"zoralurk"}, storage_start = 200258, storage = 91058, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["badger"] = {monster_race={"badger"}, storage_start = 200259, storage = 91059, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["kreebosh the exile"] = {monster_race={"kreebosh the exile"}, storage_start = 200260, storage = 91060, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["svoren the mad"] = {monster_race={"svoren the mad"}, storage_start = 200261, storage = 91061, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["orcus the cruel"] = {monster_race={"orcus the cruel"}, storage_start = 200262, storage = 91062, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["the dark dancer"] = {monster_race={"the dark dancer"}, storage_start = 200263, storage = 91063, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["dragon lord vip ii"] = {monster_race={"dragon lord vip ii"}, storage_start = 200264, storage = 91064, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["hydra vip ii"] = {monster_race={"hydra vip ii"}, storage_start = 200265, storage = 91065, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["frost dragon vip ii"] = {monster_race={"frost dragon vip ii"}, storage_start = 200266, storage = 91066, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["grim reaper vip ii"] = {monster_race={"grim reaper vip ii"}, storage_start = 200267, storage = 91067, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["demon vip ii"] = {monster_race={"demon vip ii"}, storage_start = 200268, storage = 91068, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["apocalypse vip iii"] = {monster_race={"apocalypse vip iii"}, storage_start = 200269, storage = 91069, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["frost dragon vip iii"] = {monster_race={"frost dragon vip iii"}, storage_start = 200270, storage = 91070, count = 1000000, exp = 100000000000000, money = 100000000000},
    ["rato do inferno"] = {monster_race={"rato do inferno"}, storage_start = 200271, storage = 91071, count = 1000000, exp = 100000000000000, money = 100000000000},
["massacre"] = {monster_race={"massacre"}, storage_start = 200272, storage = 91072, count = 1000000, exp = 100000000000000, money = 100000000000},
["ghazbaran"] = {monster_race={"ghazbaran"}, storage_start = 200273, storage = 91073, count = 1000000, exp = 100000000000000, money = 100000000000},
["donate demon"] = {monster_race={"donate demon"}, storage_start = 200274, storage = 91074, count = 1000000, exp = 100000000000000, money = 100000000000},
["katermenio"] = {monster_race={"katermenio"}, storage_start = 200275, storage = 91075, count = 1000000, exp = 100000000000000, money = 100000000000},
["apolo +7"] = {monster_race={"apolo +7"}, storage_start = 200276, storage = 91076, count = 1000000, exp = 100000000000000, money = 100000000000},
["annihilon"] = {monster_race={"annihilon"}, storage_start = 200277, storage = 91077, count = 1000000, exp = 100000000000000, money = 100000000000},
["golgordan"] = {monster_race={"golgordan"}, storage_start = 200278, storage = 91078, count = 1000000, exp = 100000000000000, money = 100000000000},
["klaskblow"] = {monster_race={"klaskblow"}, storage_start = 200279, storage = 91079, count = 1000000, exp = 100000000000000, money = 100000000000},
["belial +100"] = {monster_race={"belial +100"}, storage_start = 200280, storage = 91080, count = 1000000, exp = 100000000000000, money = 100000000000},
["apocalypse"] = {monster_race={"apocalypse"}, storage_start = 200281, storage = 91081, count = 1000000, exp = 100000000000000, money = 100000000000},
["zugurosh +33"] = {monster_race={"zugurosh +33"}, storage_start = 200282, storage = 91082, count = 1000000, exp = 100000000000000, money = 100000000000},
["lucifer +100"] = {monster_race={"lucifer +100"}, storage_start = 200283, storage = 91083, count = 1000000, exp = 100000000000000, money = 100000000000}
}

configbosses_task = {
{race = "minotaur",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},
{race = "necromancer",Playerpos = {x = 196, y = 39, z = 7}, FromPosToPos = {{x = 195, y = 37, z = 7},{x = 198, y = 41, z = 7}}, time = 5},
{race = "dragon",Playerpos = {x = 208, y = 59, z = 7}, FromPosToPos = {{x = 206, y = 56, z = 7},{x = 209, y = 65, z = 7}}, time = 5}
}

function CheckTask(cid)
for k, v in pairs(tasktabble) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end
end
return false
end
function finisheAllTask(cid)
local config = {
exp = {true,1000},
money = {true,200000},
items ={false,{{2124,2},{2173,1}}},
premium ={true,5}
}
local x = true
for k, v in pairs(tasktabble) do
if tonumber(getPlayerStorageValue(cid,v.storage)) then
x = false
end
end
if x == true then
setPlayerStorageValue(cid, 521456, 0)
local b = getGlobalStorageValue(63005) if b == -1 then b = 1 end
if b < 11 then
setGlobalStorageValue(63005,b+1)
doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')
doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)
doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)
doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)
if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end
doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")
end
end
end
function HavePlayerPosition(cid, from, to)
    return isInRange(getPlayerPosition(cid), from, to) and true or false
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doAddItemsFromList(cid,items) -- by vodka
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
local count = items[i][2]
while count > 0 do
if isItemStackable(items[i][1]) then
doPlayerAddItemStacking(cid, items[i][1], 1)
else
doPlayerAddItem(cid, items[i][1],1)
end
count = count - 1
end
end
end
end
        function pairsByKeys(t, f)
          local a = {}
          for n in pairs(t) do table.insert(a, n) end
          table.sort(a, f)
          local i = 0
          local iter = function ()
                i = i + 1
                if a[i] == nil then return nil
                else return a[i], t[a[i]]
                end
          end
          return iter
        end
]]></config>
<event type="login" name="TaskLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "KillTask")
return true
end]]></event>
<talkaction words="!task" event="buffer"><![CDATA[
domodlib('task_func')
local param = string.lower(param)
if param == "rank" then
getRankStorage(cid, 521456, 20, "Task Rank Finalizadas") return true
end
local str = ""
str = str .. "-=[Task Completed]=-\n\n"
for k, v in pairsByKeys(tasktabble) do
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
str = str..k.." = ".. (not tonumber(contagem) and "["..contagem.."]" or "["..((contagem)-1).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)
]]></talkaction>   
<event type="kill" name="KillTask" event="script"><![CDATA[
domodlib('task_func')
function onKill(cid, target, lastHit)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>
 
Last edited:
You can't have two globals named the same, one will overwrite the over depending on loading order.

Keep everything the same for your first NPC, but for the second NPC, rename everything referencing "tasktabble" to "tasktabble2", including the table itself.
 
NO FUNCTION

LUA:
<?xml version="1.0" encoding="UTF-8"?> 
<mod name="Blessed Task" version="3.0" author="Vodkart" contact="xtibia.com" enabled="yes"> 
<config name="task_func_rgb"><![CDATA[

tasktabble = {
    ["asuras"] = {monster_race={"asuras"}, storage_start = 200284, storage = 91084, count = 717217, exp = 100000000000000, money = 100000000000},
    ["bashmus"] = {monster_race={"bashmus"}, storage_start = 200285, storage = 91085, count = 717217, exp = 100000000000000, money = 100000000000},
    ["carnivors"] = {monster_race={"carnivors"}, storage_start = 200286, storage = 91086, count = 717217, exp = 100000000000000, money = 100000000000},
["deathlings"] = {monster_race={"deathlings"}, storage_start = 200287, storage = 91087, count = 717217, exp = 100000000000000, money = 100000000000},
    ["dreamelves"] = {monster_race={"dreamelves"}, storage_start = 200288, storage = 91088, count = 717217, exp = 100000000000000, money = 100000000000},
    ["forest monsters"] = {monster_race={"forest monsters"}, storage_start = 200289, storage = 91089, count = 717217, exp = 100000000000000, money = 100000000000},
    ["lost souls"] = {monster_race={"lost souls"}, storage_start = 200290, storage = 91090, count = 717217, exp = 100000000000000, money = 100000000000},
    ["underwaters"] = {monster_race={"underwaters"}, storage_start = 200291, storage = 91091, count = 717217, exp = 100000000000000, money = 100000000000},
    ["goannas"] = {monster_race={"goannas"}, storage_start = 200292, storage = 91092, count = 717217, exp = 100000000000000, money = 100000000000},
    ["iksupans"] = {monster_race={"iksupans"}, storage_start = 200293, storage = 91093, count = 717217, exp = 100000000000000, money = 100000000000},
    ["ingols"] = {monster_race={"ingols"}, storage_start = 200294, storage = 91094, count = 717217, exp = 100000000000000, money = 100000000000},
    ["mercurial menace"] = {monster_race={"mercurial menace"}, storage_start = 200295, storage = 91095, count = 717217, exp = 1000000000000000, money = 100000000000},
    ["nagas"] = {monster_race={"nagas"}, storage_start = 200296, storage = 91096, count = 717217, exp = 100000000000000, money = 100000000000},
    ["savants"] = {monster_race={"savants"}, storage_start = 200297, storage = 91097, count = 717217, exp = 100000000000000, money = 100000000000},
    ["spectres"] = {monster_race={"spectres"}, storage_start = 200298, storage = 91098, count = 717217, exp = 100000000000000, money = 100000000000},
    ["wingeds"] = {monster_race={"wingeds"}, storage_start = 200299, storage = 91099, count = 717217, exp = 100000000000000, money = 100000000000},
}

configbosses_task = {
{race = "minotaur",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},
{race = "necromancer",Playerpos = {x = 196, y = 39, z = 7}, FromPosToPos = {{x = 195, y = 37, z = 7},{x = 198, y = 41, z = 7}}, time = 5},
{race = "dragon",Playerpos = {x = 208, y = 59, z = 7}, FromPosToPos = {{x = 206, y = 56, z = 7},{x = 209, y = 65, z = 7}}, time = 5}
}

function CheckTask(cid)
for k, v in pairs(tasktabble2) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end
end
return false
end
function finisheAllTask(cid)
local config = {
exp = {true,1000},
money = {true,200000},
items ={false,{{2124,2},{2173,1}}},
premium ={true,5}
}
local x = true
for k, v in pairs(tasktabble2) do
if tonumber(getPlayerStorageValue(cid,v.storage)) then
x = false
end
end
if x == true then
setPlayerStorageValue(cid, 781456, 0)
local b = getGlobalStorageValue(45005) if b == -1 then b = 1 end
if b < 11 then
setGlobalStorageValue(45005,b+1)
doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')
doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)
doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)
doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)
if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end
doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")
end
end
end
function HavePlayerPosition(cid, from, to)
    return isInRange(getPlayerPosition(cid), from, to) and true or false
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doAddItemsFromList(cid,items) -- by vodka
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
local count = items[i][2]
while count > 0 do
if isItemStackable(items[i][1]) then
doPlayerAddItemStacking(cid, items[i][1], 1)
else
doPlayerAddItem(cid, items[i][1],1)
end
count = count - 1
end
end
end
end
        function pairsByKeys(t, f)
          local a = {}
          for n in pairs(t) do table.insert(a, n) end
          table.sort(a, f)
          local i = 0
          local iter = function ()
                i = i + 1
                if a[i] == nil then return nil
                else return a[i], t[a[i]]
                end
          end
          return iter
        end
]]></config>
<event type="login" name="TaskLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "KillTaskrgb")
return true
end]]></event>
<talkaction words="!taskrgb" event="buffer"><![CDATA[
domodlib('task_func_rgb')
local param = string.lower(param)
if param == "rank" then
getRankStorage(cid, 781456, 30, "Task Rank Finalizadas") return true
end
local str = ""
str = str .. "-=[Task Completed]=-\n\n"
for k, v in pairsByKeys(tasktabble2) do
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
str = str..k.." = ".. (not tonumber(contagem) and "["..contagem.."]" or "["..((contagem)-1).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)
]]></talkaction>   
<event type="kill" name="KillTaskrgb" event="script"><![CDATA[
domodlib('task_func_rgb')
function onKill(cid, target, lastHit)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble2) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>

Code:
domodlib('task_func_rgb')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if isInArray({"task","tasks","missao","mission"}, msg) then
npcHandler:say("Me diga o nome do monstro que você deseja fazer a task!", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tasktabble[msg] then
if CheckTask(cid) ~= true then
local contagem = getPlayerStorageValue(cid, tasktabble[msg].storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('Desculpe, mas você já terminou a task do '..msg, cid) return true end
setPlayerStorageValue(cid, tasktabble[msg].storage_start, 1)
npcHandler:say("Parabéns, agora você está participando da missão task do "..msg..", falta matar "..string.sub(((contagem)-1)-tasktabble[msg].count, 2).." "..msg, cid)
talkState[talkUser] = 0
else
npcHandler:say('Desculpe, mas você já faz parte de uma task!', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('digite o nome correto da missão task! para mais informações digite {!taskrgb}', cid)
talkState[talkUser] = 1
end
elseif isInArray({"receber","reward","recompensa","report","reportar"}, msg) then
if CheckTask(cid) then
for k, v in pairs(tasktabble) do
racetype = k
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('você só pode receber os items uma única vez!', cid) return true end
if (((contagem)-1) >= v.count) then
for _, check in pairs(configbosses_task) do
if string.lower(check.race) == string.lower(racetype) then
local on = getPlayersOnline()
for i=1, #on do
if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
selfSay('aguarde alguns instantes, tem pessoas fazendo a task.', cid) return true
end
end
doTeleportThing(cid, check.Playerpos)
local function checkArea(cid)
if not isCreature(cid) then return LUA_ERROR end
if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
addEvent(checkArea, check.time*60*1000, cid)
end
end
local str = ""
if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." de exp" end
if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." gps" end
if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end
npcHandler:say("Obrigado pela sua ajuda Recompensas: "..(str == "" and "nenhuma" or ""..str.."").." por ter completado a task do "..k, cid)
setPlayerStorageValue(cid, v.storage, "Finished")
setPlayerStorageValue(cid, v.storage_start, 0)
setPlayerStorageValue(cid, tasktabble2, getPlayerStorageValue(cid, tasktabble2) == -1 and 1 or getPlayerStorageValue(cid, tasktabble2)+1)
finisheAllTask(cid)
else
npcHandler:say('Desculpe,mas você só matou '..((contagem)-1)..' de '..v.count..' '..k, cid)
end
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif isInArray({"sair","leave","exit"}, msg) then
if CheckTask(cid) then
talkState[talkUser] = 2
for k, v in pairs(tasktabble) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
storagesair = v.storage_start
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
npcHandler:say('você está participando de uma missão task do '..k..' e já tem '..((contagem)-1)..' '..k..' mortos, deseja mesmo sair?', cid)
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
setPlayerStorageValue(cid, storagesair, 0)
npcHandler:say("Você foi retirado da task com sucesso!", cid)
elseif msg == "no" then 
selfSay("Tudo bem então", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Line 5 of 1st script. Change tasktabble to tasktabble2.

Line 20 of 2nd script. Change tasktabble to tasktabble2.
Line 22 of 2nd script. Change tasktabble to tasktabble2.
Line 25 of 2nd script. Change tasktabble to tasktabble2.
Line 26 of 2nd script. Change tasktabble to tasktabble2.
Line 38 of 2nd script. Change tasktabble to tasktabble2.
Line 83 of 2nd script. Change tasktabble to tasktabble2.

Learn to use find (ctrl + f), and use find/replace to prevent mistakes like this in the future.
Post automatically merged:

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Blessed Task" version="3.0" author="Vodkart" contact="xtibia.com" enabled="yes">
<config name="task_func_rgb2"><![CDATA[

tasktabble2 = {
    ["asuras"] = {monster_race={"asuras"}, storage_start = 200284, storage = 91084, count = 717217, exp = 100000000000000, money = 100000000000},
    ["bashmus"] = {monster_race={"bashmus"}, storage_start = 200285, storage = 91085, count = 717217, exp = 100000000000000, money = 100000000000},
    ["carnivors"] = {monster_race={"carnivors"}, storage_start = 200286, storage = 91086, count = 717217, exp = 100000000000000, money = 100000000000},
["deathlings"] = {monster_race={"deathlings"}, storage_start = 200287, storage = 91087, count = 717217, exp = 100000000000000, money = 100000000000},
    ["dreamelves"] = {monster_race={"dreamelves"}, storage_start = 200288, storage = 91088, count = 717217, exp = 100000000000000, money = 100000000000},
    ["forest monsters"] = {monster_race={"forest monsters"}, storage_start = 200289, storage = 91089, count = 717217, exp = 100000000000000, money = 100000000000},
    ["lost souls"] = {monster_race={"lost souls"}, storage_start = 200290, storage = 91090, count = 717217, exp = 100000000000000, money = 100000000000},
    ["underwaters"] = {monster_race={"underwaters"}, storage_start = 200291, storage = 91091, count = 717217, exp = 100000000000000, money = 100000000000},
    ["goannas"] = {monster_race={"goannas"}, storage_start = 200292, storage = 91092, count = 717217, exp = 100000000000000, money = 100000000000},
    ["iksupans"] = {monster_race={"iksupans"}, storage_start = 200293, storage = 91093, count = 717217, exp = 100000000000000, money = 100000000000},
    ["ingols"] = {monster_race={"ingols"}, storage_start = 200294, storage = 91094, count = 717217, exp = 100000000000000, money = 100000000000},
    ["mercurial menace"] = {monster_race={"mercurial menace"}, storage_start = 200295, storage = 91095, count = 717217, exp = 1000000000000000, money = 100000000000},
    ["nagas"] = {monster_race={"nagas"}, storage_start = 200296, storage = 91096, count = 717217, exp = 100000000000000, money = 100000000000},
    ["savants"] = {monster_race={"savants"}, storage_start = 200297, storage = 91097, count = 717217, exp = 100000000000000, money = 100000000000},
    ["spectres"] = {monster_race={"spectres"}, storage_start = 200298, storage = 91098, count = 717217, exp = 100000000000000, money = 100000000000},
    ["wingeds"] = {monster_race={"wingeds"}, storage_start = 200299, storage = 91099, count = 717217, exp = 100000000000000, money = 100000000000},
}

configbosses_task = {
{race = "minotaur",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},
{race = "necromancer",Playerpos = {x = 196, y = 39, z = 7}, FromPosToPos = {{x = 195, y = 37, z = 7},{x = 198, y = 41, z = 7}}, time = 5},
{race = "dragon",Playerpos = {x = 208, y = 59, z = 7}, FromPosToPos = {{x = 206, y = 56, z = 7},{x = 209, y = 65, z = 7}}, time = 5}
}

function CheckTask(cid)
for k, v in pairs(tasktabble2) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end
end
return false
end
function finisheAllTask(cid)
local config = {
exp = {true,1000},
money = {true,200000},
items ={false,{{2124,2},{2173,1}}},
premium ={true,5}
}
local x = true
for k, v in pairs(tasktabble2) do
if tonumber(getPlayerStorageValue(cid,v.storage)) then
x = false
end
end
if x == true then
setPlayerStorageValue(cid, 781456, 0)
local b = getGlobalStorageValue(45005) if b == -1 then b = 1 end
if b < 11 then
setGlobalStorageValue(45005,b+1)
doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')
doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)
doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)
doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)
if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end
doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")
end
end
end
function HavePlayerPosition(cid, from, to)
    return isInRange(getPlayerPosition(cid), from, to) and true or false
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doAddItemsFromList(cid,items) -- by vodka
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
local count = items[i][2]
while count > 0 do
if isItemStackable(items[i][1]) then
doPlayerAddItemStacking(cid, items[i][1], 1)
else
doPlayerAddItem(cid, items[i][1],1)
end
count = count - 1
end
end
end
end
        function pairsByKeys(t, f)
          local a = {}
          for n in pairs(t) do table.insert(a, n) end
          table.sort(a, f)
          local i = 0
          local iter = function ()
                i = i + 1
                if a[i] == nil then return nil
                else return a[i], t[a[i]]
                end
          end
          return iter
        end
]]></config>
<event type="login" name="TaskLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "KillTaskrgb")
return true
end]]></event>
<talkaction words="!taskrgb" event="buffer"><![CDATA[
domodlib('task_func_rgb2')
local param = string.lower(param)
if param == "rank" then
getRankStorage(cid, 781456, 30, "Task Rank Finalizadas") return true
end
local str = ""
str = str .. "-=[Task Completed]=-\n\n"
for k, v in pairsByKeys(tasktabble2) do
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
str = str..k.." = ".. (not tonumber(contagem) and "["..contagem.."]" or "["..((contagem)-1).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)
]]></talkaction>  
<event type="kill" name="KillTaskrgb" event="script"><![CDATA[
domodlib('task_func_rgb2')
function onKill(cid, target, lastHit)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble2) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>
LUA:
domodlib('task_func_rgb2')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if isInArray({"task","tasks","missao","mission"}, msg) then
npcHandler:say("Me diga o nome do monstro que você deseja fazer a task!", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tasktabble2[msg] then
if CheckTask(cid) ~= true then
local contagem = getPlayerStorageValue(cid, tasktabble2[msg].storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('Desculpe, mas você já terminou a task do '..msg, cid) return true end
setPlayerStorageValue(cid, tasktabble2[msg].storage_start, 1)
npcHandler:say("Parabéns, agora você está participando da missão task do "..msg..", falta matar "..string.sub(((contagem)-1)-tasktabble2[msg].count, 2).." "..msg, cid)
talkState[talkUser] = 0
else
npcHandler:say('Desculpe, mas você já faz parte de uma task!', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('digite o nome correto da missão task! para mais informações digite {!taskrgb}', cid)
talkState[talkUser] = 1
end
elseif isInArray({"receber","reward","recompensa","report","reportar"}, msg) then
if CheckTask(cid) then
for k, v in pairs(tasktabble2) do
racetype = k
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('você só pode receber os items uma única vez!', cid) return true end
if (((contagem)-1) >= v.count) then
for _, check in pairs(configbosses_task) do
if string.lower(check.race) == string.lower(racetype) then
local on = getPlayersOnline()
for i=1, #on do
if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
selfSay('aguarde alguns instantes, tem pessoas fazendo a task.', cid) return true
end
end
doTeleportThing(cid, check.Playerpos)
local function checkArea(cid)
if not isCreature(cid) then return LUA_ERROR end
if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
addEvent(checkArea, check.time*60*1000, cid)
end
end
local str = ""
if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." de exp" end
if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." gps" end
if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end
npcHandler:say("Obrigado pela sua ajuda Recompensas: "..(str == "" and "nenhuma" or ""..str.."").." por ter completado a task do "..k, cid)
setPlayerStorageValue(cid, v.storage, "Finished")
setPlayerStorageValue(cid, v.storage_start, 0)
setPlayerStorageValue(cid, tasktabble2, getPlayerStorageValue(cid, tasktabble2) == -1 and 1 or getPlayerStorageValue(cid, tasktabble2)+1)
finisheAllTask(cid)
else
npcHandler:say('Desculpe,mas você só matou '..((contagem)-1)..' de '..v.count..' '..k, cid)
end
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif isInArray({"sair","leave","exit"}, msg) then
if CheckTask(cid) then
talkState[talkUser] = 2
for k, v in pairs(tasktabble2) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
storagesair = v.storage_start
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
npcHandler:say('você está participando de uma missão task do '..k..' e já tem '..((contagem)-1)..' '..k..' mortos, deseja mesmo sair?', cid)
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
setPlayerStorageValue(cid, storagesair, 0)
npcHandler:say("Você foi retirado da task com sucesso!", cid)
elseif msg == "no" then
selfSay("Tudo bem então", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
NO FUNCTION

LUA:
<?xml version="1.0" encoding="UTF-8"?> 
<mod name="Blessed Task" version="3.0" author="Vodkart" contact="xtibia.com" enabled="yes"> 
<config name="task_func_rgb"><![CDATA[

tasktabble2 = {
    ["asuras"] = {monster_race={"asuras"}, storage_start = 200284, storage = 91084, count = 717217, exp = 100000000000000, money = 100000000000},
    ["bashmus"] = {monster_race={"bashmus"}, storage_start = 200285, storage = 91085, count = 717217, exp = 100000000000000, money = 100000000000},
    ["carnivors"] = {monster_race={"carnivors"}, storage_start = 200286, storage = 91086, count = 717217, exp = 100000000000000, money = 100000000000},
["deathlings"] = {monster_race={"deathlings"}, storage_start = 200287, storage = 91087, count = 717217, exp = 100000000000000, money = 100000000000},
    ["dreamelves"] = {monster_race={"dreamelves"}, storage_start = 200288, storage = 91088, count = 717217, exp = 100000000000000, money = 100000000000},
    ["forest monsters"] = {monster_race={"forest monsters"}, storage_start = 200289, storage = 91089, count = 717217, exp = 100000000000000, money = 100000000000},
    ["lost souls"] = {monster_race={"lost souls"}, storage_start = 200290, storage = 91090, count = 717217, exp = 100000000000000, money = 100000000000},
    ["underwaters"] = {monster_race={"underwaters"}, storage_start = 200291, storage = 91091, count = 717217, exp = 100000000000000, money = 100000000000},
    ["goannas"] = {monster_race={"goannas"}, storage_start = 200292, storage = 91092, count = 717217, exp = 100000000000000, money = 100000000000},
    ["iksupans"] = {monster_race={"iksupans"}, storage_start = 200293, storage = 91093, count = 717217, exp = 100000000000000, money = 100000000000},
    ["ingols"] = {monster_race={"ingols"}, storage_start = 200294, storage = 91094, count = 717217, exp = 100000000000000, money = 100000000000},
    ["mercurial menace"] = {monster_race={"mercurial menace"}, storage_start = 200295, storage = 91095, count = 717217, exp = 1000000000000000, money = 100000000000},
    ["nagas"] = {monster_race={"nagas"}, storage_start = 200296, storage = 91096, count = 717217, exp = 100000000000000, money = 100000000000},
    ["savants"] = {monster_race={"savants"}, storage_start = 200297, storage = 91097, count = 717217, exp = 100000000000000, money = 100000000000},
    ["spectres"] = {monster_race={"spectres"}, storage_start = 200298, storage = 91098, count = 717217, exp = 100000000000000, money = 100000000000},
    ["wingeds"] = {monster_race={"wingeds"}, storage_start = 200299, storage = 91099, count = 717217, exp = 100000000000000, money = 100000000000},
}

configbosses_task = {
{race = "minotaur",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},
{race = "necromancer",Playerpos = {x = 196, y = 39, z = 7}, FromPosToPos = {{x = 195, y = 37, z = 7},{x = 198, y = 41, z = 7}}, time = 5},
{race = "dragon",Playerpos = {x = 208, y = 59, z = 7}, FromPosToPos = {{x = 206, y = 56, z = 7},{x = 209, y = 65, z = 7}}, time = 5}
}

function CheckTask(cid)
for k, v in pairs(tasktabble2) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end
end
return false
end
function finisheAllTask(cid)
local config = {
exp = {true,1000},
money = {true,200000},
items ={false,{{2124,2},{2173,1}}},
premium ={true,5}
}
local x = true
for k, v in pairs(tasktabble2) do
if tonumber(getPlayerStorageValue(cid,v.storage)) then
x = false
end
end
if x == true then
setPlayerStorageValue(cid, 521456, 0)
local b = getGlobalStorageValue(63005) if b == -1 then b = 1 end
if b < 11 then
setGlobalStorageValue(63005,b+1)
doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')
doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)
doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)
doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)
if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end
doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")
end
end
end
function HavePlayerPosition(cid, from, to)
    return isInRange(getPlayerPosition(cid), from, to) and true or false
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doAddItemsFromList(cid,items) -- by vodka
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
local count = items[i][2]
while count > 0 do
if isItemStackable(items[i][1]) then
doPlayerAddItemStacking(cid, items[i][1], 1)
else
doPlayerAddItem(cid, items[i][1],1)
end
count = count - 1
end
end
end
end
        function pairsByKeys(t, f)
          local a = {}
          for n in pairs(t) do table.insert(a, n) end
          table.sort(a, f)
          local i = 0
          local iter = function ()
                i = i + 1
                if a[i] == nil then return nil
                else return a[i], t[a[i]]
                end
          end
          return iter
        end
]]></config>
<event type="login" name="TaskLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "KillTaskrgb")
return true
end]]></event>
<talkaction words="!taskrgb" event="buffer"><![CDATA[
domodlib('task_func_rgb')
local param = string.lower(param)
if param == "rank" then
getRankStorage(cid, 521456, 20, "Task Rank Finalizadas") return true
end
local str = ""
str = str .. "-=[Task Completed]=-\n\n"
for k, v in pairsByKeys(tasktabble2) do
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
str = str..k.." = ".. (not tonumber(contagem) and "["..contagem.."]" or "["..((contagem)-1).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)
]]></talkaction>   
<event type="kill" name="KillTaskrgb" event="script"><![CDATA[
domodlib('task_func_rgb')
function onKill(cid, target, lastHit)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble2) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>

Code:
domodlib('task_func_rgb')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if isInArray({"task","tasks","missao","mission"}, msg) then
npcHandler:say("Me diga o nome do monstro que você deseja fazer a task!", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tasktabble2[msg] then
if CheckTask(cid) ~= true then
local contagem = getPlayerStorageValue(cid, tasktabble2[msg].storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('Desculpe, mas você já terminou a task do '..msg, cid) return true end
setPlayerStorageValue(cid, tasktabble2[msg].storage_start, 1)
npcHandler:say("Parabéns, agora você está participando da missão task do "..msg..", falta matar "..string.sub(((contagem)-1)-tasktabble2[msg].count, 2).." "..msg, cid)
talkState[talkUser] = 0
else
npcHandler:say('Desculpe, mas você já faz parte de uma task!', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('digite o nome correto da missão task! para mais informações digite {!taskrgb}', cid)
talkState[talkUser] = 1
end
elseif isInArray({"receber","reward","recompensa","report","reportar"}, msg) then
if CheckTask(cid) then
for k, v in pairs(tasktabble22) do
racetype = k
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('você só pode receber os items uma única vez!', cid) return true end
if (((contagem)-1) >= v.count) then
for _, check in pairs(configbosses_task) do
if string.lower(check.race) == string.lower(racetype) then
local on = getPlayersOnline()
for i=1, #on do
if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
selfSay('aguarde alguns instantes, tem pessoas fazendo a task.', cid) return true
end
end
doTeleportThing(cid, check.Playerpos)
local function checkArea(cid)
if not isCreature(cid) then return LUA_ERROR end
if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
addEvent(checkArea, check.time*60*1000, cid)
end
end
local str = ""
if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." de exp" end
if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." gps" end
if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end
npcHandler:say("Obrigado pela sua ajuda Recompensas: "..(str == "" and "nenhuma" or ""..str.."").." por ter completado a task do "..k, cid)
setPlayerStorageValue(cid, v.storage, "Finished")
setPlayerStorageValue(cid, v.storage_start, 0)
setPlayerStorageValue(cid, 791456, getPlayerStorageValue(cid, 791456) == -1 and 1 or getPlayerStorageValue(cid, 791456)+1)
finisheAllTask(cid)
else
npcHandler:say('Desculpe,mas você só matou '..((contagem)-1)..' de '..v.count..' '..k, cid)
end
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif isInArray({"sair","leave","exit"}, msg) then
if CheckTask(cid) then
talkState[talkUser] = 2
for k, v in pairs(tasktabble22) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
storagesair = v.storage_start
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
npcHandler:say('você está participando de uma missão task do '..k..' e já tem '..((contagem)-1)..' '..k..' mortos, deseja mesmo sair?', cid)
end
end
else
npcHandler:say("você não está em nenhuma missão task", cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
setPlayerStorageValue(cid, storagesair, 0)
npcHandler:say("Você foi retirado da task com sucesso!", cid)
elseif msg == "no" then 
selfSay("Tudo bem então", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
@Gesior.pl Simple Task Function Blessed Tasks not function.
 

Attachments

Last edited:
Back
Top