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

Lua Task system: Problem with sharing tasks in party

tiag0_bn

Well-Known Member
Joined
Dec 8, 2011
Messages
181
Reaction score
50
my task system doesn't share the task for everyone in the party... someone would know how to help me

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 = {
["trolls"] = {monster_race={"troll","frost troll","furious troll","island troll","swamp troll","troll champion","troll legionnaire"}, storage_site = 800201, storage_start = 200201, storage = 91001,count = 300,exp = 10000,money = 5000,reward = {{2392,1}}},
["goblins"] = {monster_race={"goblin","goblin assassin","goblin leader"}, storage_site = 800202,storage_start = 200201, storage_start = 200202, storage = 91002,count = 300,exp = 10000,money = 10000, reward = {{2430,1}}},
["rotworms"] = {monster_race={"rotworm","carrion worm"}, storage_site = 800203, storage_start = 200203, storage = 91003,count = 300,exp = 30000,money = 10000, reward = {{2436,1}}},
["cyclops"] = {monster_race={"cyclops","cyclops smith","cyclops drone"}, storage_site = 800204, storage_start = 200204, storage = 91004, count = 400,exp = 60000, money = 15000, reward = {{2477,1}}, reward = {{2476,1}}},
["dwarf guards"] = {monster_race={"dwarf guard"}, storage_site = 800205, storage_start = 200205, storage = 91005,count = 300,exp = 100000, money = 15000, reward = {{6979,1}}},
["orc warlords"] = {monster_race={"orc warlord"}, storage_site = 800206, storage_start = 200248, storage = 91048,count = 250,exp = 150000, money = 25000, reward = {{5685,1}}},
["dwarfs"] = {monster_race={"dwarf guard","dwarf","dwarf soldier"}, storage_site = 800207, storage_start = 200249, storage = 91049, count = 300, exp = 40000, money = 10000, reward = {{5579,1}}},
["orcs"] = {monster_race={"orc","orc warrior","orc warlord","orc Shaman","orc rider","orc leader","orc berserker","orc spearman"}, storage_site = 800208, storage_start = 200206, storage = 91006,count = 300,exp = 30000,money = 10000, reward = {{2519,1}}},
["tarantulas"] = {monster_race={"tarantula"}, storage_site = 800209, storage_start = 200207, storage = 91007,count = 200,exp = 55000,money = 10000, reward = {{2516,1}}},
["demon skeletons"] = {monster_race={"demon skeleton"}, storage_site = 800210, storage_start = 200208, storage = 91008,count = 200,exp = 120000, reward = {{6241,1}}},
["minotaurs"] = {monster_race={"minotaur","minotaur archer","minotaur mage","minotaur guard"}, storage_site = 800211, storage_start = 200209, storage = 91009,count = 500,exp = 75000,money = 10000, reward = {{2391,1}}},
["necromancers"] = {monster_race={"necromancer","priestess"}, storage_site = 800212, storage_start = 200210, storage = 91010,count= 350, exp = 350000, reward = {{2195,1}}},
["Diabolic Spellweaver"] = {monster_race={"Diabolic Spellweaver"}, storage_site = 800213, storage_start = 200211, storage = 91011,count= 350, exp = 250000, reward = {{2195,1}}},
["apes"] = {monster_race={"kongra","sibang","merlkin"}, storage_site = 800214, storage_start = 200212, storage = 91012,count= 400, exp = 60000, money = 15000, reward = {{2426,1}}},
["fire elementals"] = {monster_race={"fire elemental"}, storage_site = 800215, storage_start = 200213, storage = 91013,count= 150, exp = 110000},
["dragons"] = {monster_race={"dragon","dragon lord","frost dragon"}, storage_site = 800216, storage_start = 200214, storage = 91014,count= 400, exp = 250000, money = 25000, reward = {{2492,1}}},
["pandas"] = {monster_race={"panda"}, storage_site = 800217, storage_start = 200215, storage = 91015,count = 50, exp = 5500,money = 5000},
["giant spiders"] = {monster_race={"giant spider"}, storage_site = 800218, storage_start = 200216, storage = 91016,count = 250, exp = 250000, money = 25000, reward = {{2169,3}}},
["hydras"] = {monster_race={"hydra"}, storage_site = 800219, storage_start = 200217, storage = 91017,count = 350, exp = 450000, reward = {{2393,1}}},
["serpent spawns"] = {monster_race={"serpent spawn"}, storage_site = 800220, storage_start = 200218, storage = 91018,count = 350, exp = 650000, reward = {{2645,1}}},
["behemoths"] = {monster_race={"behemoth"}, storage_site = 800221, storage_start = 200219, storage = 91019,count = 300, exp = 450000, money = 40000, reward = {{2575,1}}},
["crocodiles"] = {monster_race={"crocodile"}, storage_site = 800222, storage_start = 200220, storage = 91020,count = 150, exp = 11000, money = 2500, reward = {{7847,1}}},
["demons"] = {monster_race={"demon"}, storage_site = 800223, storage_start = 200221, storage = 91021,count = 666, exp = 1000000, reward = {{2646,1}} },
["terror birds"] = {monster_race={"terror bird"}, storage_site = 800224, storage_start = 200222, storage = 91022,count = 50, exp = 80000, money = 10000},
["larvas"] = {monster_race={"larva"}, storage_site = 800225, storage_start = 200223, storage = 91023,count = 300, exp = 30000, money = 10000, reward = {{2392,1}}},
["humans"] = {monster_race={"smuggler","bandit","amazon","assassin","hero","black knight","stalker","hunter","valkyrie","dark monk","monk","necromancer","witch","wild warrior","priestess"}, storage_site = 800226, storage_start = 200224, storage = 91024,count = 500, exp = 60000, money = 15000, reward = {{2656,1}}},
["scarab"] = {monster_race={"scarab"}, storage_site = 800227, storage_start = 200225, storage = 91025,count = 400, exp = 60000, money = 20000, reward = {{2432,1}}},
["vampires"] = {monster_race={"vampire"}, storage_site = 800228, storage_start = 200226, storage = 91026,count = 400, exp = 350000, reward = {{2534,1}}},
["ancient scarabs"] = {monster_race={"ancient scarab"}, storage_site = 800229, storage_start = 200227, storage = 91027,count = 300, exp = 150000, money = 25000, reward = {{6241,1}}},
["heros"] = {monster_race={"hero"}, storage_site = 800230, storage_start = 200228, storage = 91028,count = 250, exp = 150000, reward = {{2488,1}}},
["black knights"] = {monster_race={"black knight"}, storage_site = 800231, storage_start = 200229, storage = 91029,count = 250, exp = 350000, money = 35000, reward = {{2466,1}}},
["dragon lords"] = {monster_race={"dragon lord"}, storage_site = 800232, storage_start = 200230, storage = 91030,count = 550, exp = 750000, reward = {{2492,1}}},
["warlocks"] = {monster_race={"warlock"}, storage_site = 800233, storage_start = 200231, storage = 91031,count = 400, exp = 750000, money = 75000, reward = {{6386,1}}},
["lost souls"] = {monster_race={"lost soul"}, storage_site = 800234, storage_start = 200232, storage = 91032,count = 150, exp = 920000},
["nightmares"] = {monster_race={"nightmare"}, storage_site = 800235, storage_start = 200233, storage = 91033,count = 100, exp = 890000},
["dark torturers"] = {monster_race={"dark torturer"}, storage_site = 800236, storage_start = 200234, storage = 91034,count = 250, exp = 1250000},
["plaguesmiths"] = {monster_race={"plaguesmith"}, storage_site = 800237, storage_start = 200235, storage = 91035,count = 350, exp = 950000},
["defilers"] = {monster_race={"defiler"}, storage_site = 800238, storage_start = 200236, storage = 91036,count = 250, exp = 950000},
["hellfire fighters"] = {monster_race={"hellfire fighter"}, storage_site = 800239, storage_start = 200237, storage = 91037,count = 250, exp = 1500000},
["destroyers"] = {monster_race={"destroyer"}, storage_site = 800240, storage_start = 200238, storage = 91038,count = 200, exp = 900000},
["diabolic imps"] = {monster_race={"diabolic imp"}, storage_site = 800241, storage_start = 200239, storage = 91039,count = 150, exp = 700000},
["hellhounds"] = {monster_race={"hellhound"}, storage_site = 800242, storage_start = 200240, storage = 91040,count = 500, exp = 1700000},
["blightwalkers"] = {monster_race={"blightwalker"}, storage_site = 800243, storage_start = 200241, storage = 91041,count = 200, exp = 950000},
["hand of cursed fates"] = {monster_race={"hand of cursed fate"}, storage_site = 800244, storage_start = 200242, storage = 91042,count = 150, exp = 1200000},
["son of verminors"] = {monster_race={"son of verminor"}, storage_site = 800245, storage_start = 200243, storage = 91043,count = 150, exp = 500000},
["juggernauts"] = {monster_race={"juggernaut"}, storage_site = 800246, storage_start = 200244, storage = 91044,count = 200, exp = 1550000},
["undead dragons"] = {monster_race={"undead dragon"}, storage_site = 800247, storage_start = 200245, storage = 91045,count = 200, exp = 1300000},
["betrayed wraiths"] = {monster_race={"betrayed wraiths"}, storage_site = 800248, storage_start = 200246, storage = 91046,count = 200, exp = 900000},
["phantasms"] = {monster_race={"phantasms"}, storage_site = 800249, storage_start = 200247, storage = 91047,count = 180, exp = 850000},
["ghouls"] = {monster_race={"ghoul"}, storage_site = 800250, storage_start = 200250, storage = 91050,count = 300, exp = 30000,money = 10000, reward = {{2392,1}}},
["lizards"] = {monster_race={"lizard sentinel","lizard snakecharmer","lizard templar"}, storage_site = 800251, storage_start = 200251, storage = 91051,count = 500, exp = 60000,money = 15000, reward = {{6978,1}}},
["Ice Witch"] = {monster_race={"Ice Witch"}, storage_site = 800252, storage_start = 200252, storage = 91052, count= 350, exp = 150000, money = 25000 , reward = {{2195,1}}},
["orc leaders"] = {monster_race={"orc leader"}, storage_site = 800253, storage_start = 200253, storage = 91053,count = 350, exp = 105000,money = 5000}

}


configbosses_task = {}

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,100000},
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>   
<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>
 
my task system doesn't share the task for everyone in the party... someone would know how to help me

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 = {
["trolls"] = {monster_race={"troll","frost troll","furious troll","island troll","swamp troll","troll champion","troll legionnaire"}, storage_site = 800201, storage_start = 200201, storage = 91001,count = 300,exp = 10000,money = 5000,reward = {{2392,1}}},
["goblins"] = {monster_race={"goblin","goblin assassin","goblin leader"}, storage_site = 800202,storage_start = 200201, storage_start = 200202, storage = 91002,count = 300,exp = 10000,money = 10000, reward = {{2430,1}}},
["rotworms"] = {monster_race={"rotworm","carrion worm"}, storage_site = 800203, storage_start = 200203, storage = 91003,count = 300,exp = 30000,money = 10000, reward = {{2436,1}}},
["cyclops"] = {monster_race={"cyclops","cyclops smith","cyclops drone"}, storage_site = 800204, storage_start = 200204, storage = 91004, count = 400,exp = 60000, money = 15000, reward = {{2477,1}}, reward = {{2476,1}}},
["dwarf guards"] = {monster_race={"dwarf guard"}, storage_site = 800205, storage_start = 200205, storage = 91005,count = 300,exp = 100000, money = 15000, reward = {{6979,1}}},
["orc warlords"] = {monster_race={"orc warlord"}, storage_site = 800206, storage_start = 200248, storage = 91048,count = 250,exp = 150000, money = 25000, reward = {{5685,1}}},
["dwarfs"] = {monster_race={"dwarf guard","dwarf","dwarf soldier"}, storage_site = 800207, storage_start = 200249, storage = 91049, count = 300, exp = 40000, money = 10000, reward = {{5579,1}}},
["orcs"] = {monster_race={"orc","orc warrior","orc warlord","orc Shaman","orc rider","orc leader","orc berserker","orc spearman"}, storage_site = 800208, storage_start = 200206, storage = 91006,count = 300,exp = 30000,money = 10000, reward = {{2519,1}}},
["tarantulas"] = {monster_race={"tarantula"}, storage_site = 800209, storage_start = 200207, storage = 91007,count = 200,exp = 55000,money = 10000, reward = {{2516,1}}},
["demon skeletons"] = {monster_race={"demon skeleton"}, storage_site = 800210, storage_start = 200208, storage = 91008,count = 200,exp = 120000, reward = {{6241,1}}},
["minotaurs"] = {monster_race={"minotaur","minotaur archer","minotaur mage","minotaur guard"}, storage_site = 800211, storage_start = 200209, storage = 91009,count = 500,exp = 75000,money = 10000, reward = {{2391,1}}},
["necromancers"] = {monster_race={"necromancer","priestess"}, storage_site = 800212, storage_start = 200210, storage = 91010,count= 350, exp = 350000, reward = {{2195,1}}},
["Diabolic Spellweaver"] = {monster_race={"Diabolic Spellweaver"}, storage_site = 800213, storage_start = 200211, storage = 91011,count= 350, exp = 250000, reward = {{2195,1}}},
["apes"] = {monster_race={"kongra","sibang","merlkin"}, storage_site = 800214, storage_start = 200212, storage = 91012,count= 400, exp = 60000, money = 15000, reward = {{2426,1}}},
["fire elementals"] = {monster_race={"fire elemental"}, storage_site = 800215, storage_start = 200213, storage = 91013,count= 150, exp = 110000},
["dragons"] = {monster_race={"dragon","dragon lord","frost dragon"}, storage_site = 800216, storage_start = 200214, storage = 91014,count= 400, exp = 250000, money = 25000, reward = {{2492,1}}},
["pandas"] = {monster_race={"panda"}, storage_site = 800217, storage_start = 200215, storage = 91015,count = 50, exp = 5500,money = 5000},
["giant spiders"] = {monster_race={"giant spider"}, storage_site = 800218, storage_start = 200216, storage = 91016,count = 250, exp = 250000, money = 25000, reward = {{2169,3}}},
["hydras"] = {monster_race={"hydra"}, storage_site = 800219, storage_start = 200217, storage = 91017,count = 350, exp = 450000, reward = {{2393,1}}},
["serpent spawns"] = {monster_race={"serpent spawn"}, storage_site = 800220, storage_start = 200218, storage = 91018,count = 350, exp = 650000, reward = {{2645,1}}},
["behemoths"] = {monster_race={"behemoth"}, storage_site = 800221, storage_start = 200219, storage = 91019,count = 300, exp = 450000, money = 40000, reward = {{2575,1}}},
["crocodiles"] = {monster_race={"crocodile"}, storage_site = 800222, storage_start = 200220, storage = 91020,count = 150, exp = 11000, money = 2500, reward = {{7847,1}}},
["demons"] = {monster_race={"demon"}, storage_site = 800223, storage_start = 200221, storage = 91021,count = 666, exp = 1000000, reward = {{2646,1}} },
["terror birds"] = {monster_race={"terror bird"}, storage_site = 800224, storage_start = 200222, storage = 91022,count = 50, exp = 80000, money = 10000},
["larvas"] = {monster_race={"larva"}, storage_site = 800225, storage_start = 200223, storage = 91023,count = 300, exp = 30000, money = 10000, reward = {{2392,1}}},
["humans"] = {monster_race={"smuggler","bandit","amazon","assassin","hero","black knight","stalker","hunter","valkyrie","dark monk","monk","necromancer","witch","wild warrior","priestess"}, storage_site = 800226, storage_start = 200224, storage = 91024,count = 500, exp = 60000, money = 15000, reward = {{2656,1}}},
["scarab"] = {monster_race={"scarab"}, storage_site = 800227, storage_start = 200225, storage = 91025,count = 400, exp = 60000, money = 20000, reward = {{2432,1}}},
["vampires"] = {monster_race={"vampire"}, storage_site = 800228, storage_start = 200226, storage = 91026,count = 400, exp = 350000, reward = {{2534,1}}},
["ancient scarabs"] = {monster_race={"ancient scarab"}, storage_site = 800229, storage_start = 200227, storage = 91027,count = 300, exp = 150000, money = 25000, reward = {{6241,1}}},
["heros"] = {monster_race={"hero"}, storage_site = 800230, storage_start = 200228, storage = 91028,count = 250, exp = 150000, reward = {{2488,1}}},
["black knights"] = {monster_race={"black knight"}, storage_site = 800231, storage_start = 200229, storage = 91029,count = 250, exp = 350000, money = 35000, reward = {{2466,1}}},
["dragon lords"] = {monster_race={"dragon lord"}, storage_site = 800232, storage_start = 200230, storage = 91030,count = 550, exp = 750000, reward = {{2492,1}}},
["warlocks"] = {monster_race={"warlock"}, storage_site = 800233, storage_start = 200231, storage = 91031,count = 400, exp = 750000, money = 75000, reward = {{6386,1}}},
["lost souls"] = {monster_race={"lost soul"}, storage_site = 800234, storage_start = 200232, storage = 91032,count = 150, exp = 920000},
["nightmares"] = {monster_race={"nightmare"}, storage_site = 800235, storage_start = 200233, storage = 91033,count = 100, exp = 890000},
["dark torturers"] = {monster_race={"dark torturer"}, storage_site = 800236, storage_start = 200234, storage = 91034,count = 250, exp = 1250000},
["plaguesmiths"] = {monster_race={"plaguesmith"}, storage_site = 800237, storage_start = 200235, storage = 91035,count = 350, exp = 950000},
["defilers"] = {monster_race={"defiler"}, storage_site = 800238, storage_start = 200236, storage = 91036,count = 250, exp = 950000},
["hellfire fighters"] = {monster_race={"hellfire fighter"}, storage_site = 800239, storage_start = 200237, storage = 91037,count = 250, exp = 1500000},
["destroyers"] = {monster_race={"destroyer"}, storage_site = 800240, storage_start = 200238, storage = 91038,count = 200, exp = 900000},
["diabolic imps"] = {monster_race={"diabolic imp"}, storage_site = 800241, storage_start = 200239, storage = 91039,count = 150, exp = 700000},
["hellhounds"] = {monster_race={"hellhound"}, storage_site = 800242, storage_start = 200240, storage = 91040,count = 500, exp = 1700000},
["blightwalkers"] = {monster_race={"blightwalker"}, storage_site = 800243, storage_start = 200241, storage = 91041,count = 200, exp = 950000},
["hand of cursed fates"] = {monster_race={"hand of cursed fate"}, storage_site = 800244, storage_start = 200242, storage = 91042,count = 150, exp = 1200000},
["son of verminors"] = {monster_race={"son of verminor"}, storage_site = 800245, storage_start = 200243, storage = 91043,count = 150, exp = 500000},
["juggernauts"] = {monster_race={"juggernaut"}, storage_site = 800246, storage_start = 200244, storage = 91044,count = 200, exp = 1550000},
["undead dragons"] = {monster_race={"undead dragon"}, storage_site = 800247, storage_start = 200245, storage = 91045,count = 200, exp = 1300000},
["betrayed wraiths"] = {monster_race={"betrayed wraiths"}, storage_site = 800248, storage_start = 200246, storage = 91046,count = 200, exp = 900000},
["phantasms"] = {monster_race={"phantasms"}, storage_site = 800249, storage_start = 200247, storage = 91047,count = 180, exp = 850000},
["ghouls"] = {monster_race={"ghoul"}, storage_site = 800250, storage_start = 200250, storage = 91050,count = 300, exp = 30000,money = 10000, reward = {{2392,1}}},
["lizards"] = {monster_race={"lizard sentinel","lizard snakecharmer","lizard templar"}, storage_site = 800251, storage_start = 200251, storage = 91051,count = 500, exp = 60000,money = 15000, reward = {{6978,1}}},
["Ice Witch"] = {monster_race={"Ice Witch"}, storage_site = 800252, storage_start = 200252, storage = 91052, count= 350, exp = 150000, money = 25000 , reward = {{2195,1}}},
["orc leaders"] = {monster_race={"orc leader"}, storage_site = 800253, storage_start = 200253, storage = 91053,count = 350, exp = 105000,money = 5000}

}


configbosses_task = {}

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,100000},
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>  
<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>
i think, it is because it works on player storage - or something related to it...
 
Looks like you are using tfs 0.X. I only have a solution for tfs 1.4.
You could maybe look at it for inspiration.
Lua:
local function updatePlayerProgress(player, task)
    local killCount = player:getStorageValue(task.id)
    if killCount < task.count then
        local newKillCount = killCount + 1
        player:setStorageValue(task.id, newKillCount)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You have killed " .. newKillCount .. " out of " .. task.count .. " " .. task.task_name)
    
        if newKillCount == task.count then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Congratulations you have finished the task! Talk to Bear Grylls to claim your reward.")
        end
    end
end

local function shouldGetReward(participant, killer)
    if participant:getName() == killer:getName() then
        return true
    end

    local party = killer:getParty()
    if party and party:getMemberCount() > 0 then
        local partyMembers = party:getMembers()
        local leader = party:getLeader()
        for _, member in ipairs(partyMembers) do
            if participant == member or participant == leader then
                return true
            end
        end
    end

    return false
end

local task_monster_kill = CreatureEvent("task_monster_kill")

function task_monster_kill.onKill(killer, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end

    local monsterName = target:getName()
    local task = getTask(monsterName)

    if task == nil then
        return true
    end

    for cid, _ in pairs(target:getDamageMap()) do
        local participant = Player(cid)
        if participant ~= nil and shouldGetReward(participant, killer) then
            updatePlayerProgress(participant, task)
        end
    end

    return true
end

task_monster_kill:register()
 
Looks like you are using tfs 0.X. I only have a solution for tfs 1.4.
You could maybe look at it for inspiration.
Lua:
local function updatePlayerProgress(player, task)
    local killCount = player:getStorageValue(task.id)
    if killCount < task.count then
        local newKillCount = killCount + 1
        player:setStorageValue(task.id, newKillCount)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You have killed " .. newKillCount .. " out of " .. task.count .. " " .. task.task_name)
   
        if newKillCount == task.count then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Congratulations you have finished the task! Talk to Bear Grylls to claim your reward.")
        end
    end
end

local function shouldGetReward(participant, killer)
    if participant:getName() == killer:getName() then
        return true
    end

    local party = killer:getParty()
    if party and party:getMemberCount() > 0 then
        local partyMembers = party:getMembers()
        local leader = party:getLeader()
        for _, member in ipairs(partyMembers) do
            if participant == member or participant == leader then
                return true
            end
        end
    end

    return false
end

local task_monster_kill = CreatureEvent("task_monster_kill")

function task_monster_kill.onKill(killer, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end

    local monsterName = target:getName()
    local task = getTask(monsterName)

    if task == nil then
        return true
    end

    for cid, _ in pairs(target:getDamageMap()) do
        local participant = Player(cid)
        if participant ~= nil and shouldGetReward(participant, killer) then
            updatePlayerProgress(participant, task)
        end
    end

    return true
end

task_monster_kill:register()

Hi, mind sharing full script?
 
Hi, mind sharing full script?
I can, but be aware that this script is designed for the server i am working for. Some parts might need to be changed in order to get it to work on your server.

Revscript:
Tasks.lua
Lua:
monster_tasks = {
    {
        id = 19000,
        task_name = "Trolls",
        monster_names = {"Troll", "Troll Champion", "Swamp Troll", "Frost Troll"},
        count = 150,
        rewards = {
            experience = 7000,
            points = 1,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 20
                }
            }
        }
    },
    {
        id = 19001,
        task_name = "Cyclops",
        monster_names = {"Cyclops", "Cyclops Smith", "Cyclops Drone"},
        count = 350,
        rewards = {
            experience = 89250,
            points = 2,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 40
                },
                warriorHelmet = {
                    id = 2475,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19002,
        task_name = "Orcs",
        monster_names = {"Orc", "Orc Warrior", "Orc Spearman", "Orc Berserker", "Orc Shaman", "Orc Leader", "Orc Warlord", "Orc Rider"},
        count = 300,
        rewards = {
            experience = 97500,
            points = 2,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 60
                }
            }
        }
    },
    {
        id = 19003,
        task_name = "Giant Spiders",
        monster_names = {"Giant Spider"},
        count = 200,
        rewards = {
            tome = "rare",
            experience = 180000,
            points = 3,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                yarn = {
                    id = 5886,
                    amount = 2
                }
            }
        }
    },
    {
        id = 19004,
        task_name = "Dragons",
        monster_names = {"Dragon"},
        count = 250,
        rewards = {
            tome = "rare",
            experience = 175000,
            points = 3,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19005,
        task_name = "Vampires",
        monster_names = {"Vampire"},
        count = 600,
        rewards = {
            tome = "rare",
            experience = 183000,
            points = 4,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                vampireShield = {
                    id = 2534,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19006,
        task_name = "Heroes",
        monster_names = {"Hero"},
        count = 500,
        rewards = {
            tome = "rare",
            experience = 600000,
            points = 4,
            items = {
                crownLegs = {
                    id = 2488,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19007,
        task_name = "High Class Lizards",
        monster_names = {"Lizard Chosen", "Lizard High Guard", "Lizard Dragon Priest", "Lizard Legionnaire", "Lizard Zaogun"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 660000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 4
                },
                zaoanHelmet = {
                    id = 11302,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19008,
        task_name = "Hydras",
        monster_names = {"Hydra"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 1050000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 2
                },
                boh = {
                    id = 2195,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19009,
        task_name = "Dragon Lords",
        monster_names = {"Dragon Lord"},
        count = 400,
        rewards = {
            tome = "very rare",
            experience = 840000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                royalHelmet = {
                    id = 2498,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19010,
        task_name = "Frost Dragons",
        monster_names = {"Frost Dragon"},
        count = 200,
        rewards = {
            tome = "very rare",
            experience = 420000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                dragonSlayer = {
                    id = 7402,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19011,
        task_name = "Sea serpents",
        monster_names = {"Sea Serpent", "Young Sea Serpent"},
        count = 400,
        rewards = {
            tome = "very rare",
            experience = 1320000,
            points = 4,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                crystallineArmor = {
                    id = 8878,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19012,
        task_name = "Warlocks",
        monster_names = {"Warlock", "Infernalist"},
        count = 150,
        rewards = {
            tome = "very rare",
            experience = 600000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 3
                },
                ringOfTheSky = {
                    id = 2123,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19013,
        task_name = "Behemoths",
        monster_names = {"Behemoth"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 1250000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 3
                },
                steelBoots = {
                    id = 2645,
                    amount = 1
                },
                behemothFang = {
                    id = 5893,
                    amount = 10
                },
                behemothTrophy = {
                    id = 7396,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19014,
        task_name = "Demons",
        monster_names = {"Demon"},
        count = 500,
        rewards = {
            tome = "very epic",
            experience = 3000000,
            points = 15,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 10
                },
                mms = {
                    id = 2514,
                    amount = 1
                },
                demonTrophy = {
                    id = 7393,
                    amount = 1
                }
            }
        }
    }
}

task_point_id = 19090

point_tresholds = {5, 25, 50, 100}

skinning_door_id = 19091
skinning_chest_id = 19191
khajit_door_aid = 19092
tp_door_aid = 19093
primal_door_aid = 19094
moon_backpack_chest_uid = 19195

function getTask(monsterName)
    for _, task in ipairs(monster_tasks) do
        for _, name in ipairs(task.monster_names) do
            if name == monsterName then
                return task
            end
        end
    end

    return nil
end

local function updatePlayerProgress(player, task)
    local killCount = player:getStorageValue(task.id)
    if killCount < task.count then
        local newKillCount = killCount + 1
        player:setStorageValue(task.id, newKillCount)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You have killed " .. newKillCount .. " out of " .. task.count .. " " .. task.task_name)
    
        if newKillCount == task.count then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Congratulations you have finished the task! Talk to Bear Grylls to claim your reward.")
        end
    end
end

local function shouldGetReward(participant, killer)
    if participant:getName() == killer:getName() then
        return true
    end

    local party = killer:getParty()
    if party and party:getMemberCount() > 0 then
        local partyMembers = party:getMembers()
        local leader = party:getLeader()
        for _, member in ipairs(partyMembers) do
            if participant == member or participant == leader then
                return true
            end
        end
    end

    return false
end

local task_monster_kill = CreatureEvent("task_monster_kill")

function task_monster_kill.onKill(killer, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end

    local monsterName = target:getName()
    local task = getTask(monsterName)

    if task == nil then
        return true
    end

    for cid, _ in pairs(target:getDamageMap()) do
        local participant = Player(cid)
        if participant ~= nil and shouldGetReward(participant, killer) then
            updatePlayerProgress(participant, task)
        end
    end

    return true
end

task_monster_kill:register()

local login = CreatureEvent("register_task_monster_kill")

function login.onLogin(player)

    for _, task in ipairs(monster_tasks) do
        if player:getStorageValue(task.id) == -1 then
            player:setStorageValue(task.id, 0)
        end
    end

    if player:getStorageValue(task_point_id) == -1 then
        player:setStorageValue(task_point_id, 0)
    end

    if player:getAccountStorageValue(tp_door_aid) == 1 and player:getStorageValue(tp_door_aid) ~= 1 then
        player:setStorageValue(tp_door_aid, 1)
    end   

    player:registerEvent("task_monster_kill")
    return true
end

login:register()

function compareTasks(a,b)
    return a.task_name < b.task_name
end

local talkAction = TalkAction("!tasks", "!task")

function talkAction.onSay(player, words, param)
    local points = player:getStorageValue(task_point_id)
    
    local text = "Points: " .. points .. "\n"

    table.sort(monster_tasks, compareTasks)
    for _, task in ipairs(monster_tasks) do
        local killCount = player:getStorageValue(task.id)
        text = string.format("%s \n%s: %i out of %i", text, task.task_name, killCount, task.count)
    end

    player:showTextDialog(1952, text)
    return false
end

talkAction:register()


npc/scripts - task_npc.lua
Lua:
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

npcHandler:setMessage(MESSAGE_GREET, "Hello there |PLAYERNAME|! Have you completed a {task}? Want to {trade} leather? Do you want to know how many {points} you got?")

local function rewardItems(player, rewards)
--[[    if rewards.tome then
        for _, book in ipairs(tierBooks) do
            if book.t == rewards.tome then
                local tome = Game.createItem(book.id, 1)
                enableBooks(tome)
                player:addItemEx(tome, true)
                player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got a " .. book.t .. " book!")
            end               
        end
    end You can ignore this bit-- ]]

    for _, item in pairs(rewards.items) do
        local newItem = Game.createItem(item.id, item.amount)
        local itemType = ItemType(item.id)

        if item.amount > 1 then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. item.amount .. " " .. newItem:getPluralName() .. ".")
        else
            local rarity = rollRareOrEpic()
            if rollRarity(newItem, rarity, true) > 0 then
                local articles = newItem:getArticle():splitTrimmed(" ")
                local rolledRarity = #articles > 1 and articles[2] or articles[1]

                player:getPosition():sendMagicEffect(CONST_ME_STUN)
                local spectators = Game.getSpectators(player:getPosition(), false, true, 7, 7, 5, 5)
                for i = 1, #spectators do
                    spectators[i]:say(rolledRarity, TALKTYPE_MONSTER_SAY, false, spectators[i], player:getPosition())
                end
            end
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. newItem:getArticle() .. " " .. itemType:getName() .. ".")
        end
        player:addItemEx(newItem, true)
    end
end

local function rewardPoints(player, points)
    local pointsBefore = player:getStorageValue(task_point_id)
    local pointsAfter = pointsBefore + points

    local newTreshold = false

    for key, treshold in ipairs(point_tresholds) do
        if pointsBefore < treshold and pointsAfter >= treshold then
            newTreshold = key
            --Give access to new door
            if key == 1 then
                player:setStorageValue(skinning_door_id, 1)

            elseif key == 2 then
                player:setStorageValue(khajit_door_aid, 1)

            elseif key == 4 then
                player:setStorageValue(primal_door_aid, 1)
            end
        end
    end

    player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. points .. " task points. You now have " .. pointsAfter .. " task points.")

    player:setStorageValue(task_point_id, pointsAfter)
    return newTreshold
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 player = Player(cid)

    if msgcontains(msg, "task") then
        local completedTask = nil

        for _, task in ipairs(monster_tasks) do
            local killCount = player:getStorageValue(task.id)
            if killCount >= task.count then
                completedTask = task
                break
            end
        end

        if completedTask == nil then
            selfSay("I will reward you with items, experience and task {points} if you kill enough of certain monsters. Type !tasks to check your current progress.", cid)
        else
            selfSay("Impressive! Here, take your reward for completing the " .. completedTask.task_name .. " task.", cid)
            local rewards = completedTask.rewards
            player:addExperience(rewards.experience, true)

            local reachedTreshold = rewardPoints(player, rewards.points)

            if reachedTreshold then
                if reachedTreshold == 3 then
                    if player:getAccountStorageValue(tp_door_aid) ~= 1 then
                        player:setAccountStorageValue(tp_door_aid, 1)
                        player:setStorageValue(tp_door_aid, 1)
                        selfSay("Congratulations! You reached a new rank. You and all of your characters now access my special teleport room downstairs.", cid)
                    else
                        selfSay("Congratulations! You reached a new rank. Unfortunately you have already received the reward for this rank on another character.", cid)
                    end
                else
                    selfSay("Congratulations! You reached a new rank. You now access another one of my doors downstairs.", cid)
                end
            else

            end

            rewardItems(player, rewards)

            player:setStorageValue(completedTask.id, 0)
        end
    elseif msgcontains(msg, "point") then
        local points = player:getStorageValue(task_point_id)
        selfSay("You get rewarded with task points depending on the difficulty of the task completed.\nA new door in the basement unlocks at 5, 25, 50, 100 points.\nYou currently have " .. points .. " task points.", cid)
    end

    return true
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'minotaur leather'}, 5878, 10000, 'minotaur leather')
shopModule:addBuyableItem({'lizard leather'}, 5876, 10000, 'lizard leather')
shopModule:addBuyableItem({'green dragon leather'}, 5877, 15000, 'green dragon leather')
shopModule:addBuyableItem({'red dragon leather'}, 5948, 20000, 'red dragon leather')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I can, but be aware that this script is designed for the server i am working for. Some parts might need to be changed in order to get it to work on your server.

Revscript:
Tasks.lua
Lua:
monster_tasks = {
    {
        id = 19000,
        task_name = "Trolls",
        monster_names = {"Troll", "Troll Champion", "Swamp Troll", "Frost Troll"},
        count = 150,
        rewards = {
            experience = 7000,
            points = 1,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 20
                }
            }
        }
    },
    {
        id = 19001,
        task_name = "Cyclops",
        monster_names = {"Cyclops", "Cyclops Smith", "Cyclops Drone"},
        count = 350,
        rewards = {
            experience = 89250,
            points = 2,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 40
                },
                warriorHelmet = {
                    id = 2475,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19002,
        task_name = "Orcs",
        monster_names = {"Orc", "Orc Warrior", "Orc Spearman", "Orc Berserker", "Orc Shaman", "Orc Leader", "Orc Warlord", "Orc Rider"},
        count = 300,
        rewards = {
            experience = 97500,
            points = 2,
            items = {
                platinumCoins = {
                    id = 2152,
                    amount = 60
                }
            }
        }
    },
    {
        id = 19003,
        task_name = "Giant Spiders",
        monster_names = {"Giant Spider"},
        count = 200,
        rewards = {
            tome = "rare",
            experience = 180000,
            points = 3,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                yarn = {
                    id = 5886,
                    amount = 2
                }
            }
        }
    },
    {
        id = 19004,
        task_name = "Dragons",
        monster_names = {"Dragon"},
        count = 250,
        rewards = {
            tome = "rare",
            experience = 175000,
            points = 3,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19005,
        task_name = "Vampires",
        monster_names = {"Vampire"},
        count = 600,
        rewards = {
            tome = "rare",
            experience = 183000,
            points = 4,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                vampireShield = {
                    id = 2534,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19006,
        task_name = "Heroes",
        monster_names = {"Hero"},
        count = 500,
        rewards = {
            tome = "rare",
            experience = 600000,
            points = 4,
            items = {
                crownLegs = {
                    id = 2488,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19007,
        task_name = "High Class Lizards",
        monster_names = {"Lizard Chosen", "Lizard High Guard", "Lizard Dragon Priest", "Lizard Legionnaire", "Lizard Zaogun"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 660000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 4
                },
                zaoanHelmet = {
                    id = 11302,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19008,
        task_name = "Hydras",
        monster_names = {"Hydra"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 1050000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 2
                },
                boh = {
                    id = 2195,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19009,
        task_name = "Dragon Lords",
        monster_names = {"Dragon Lord"},
        count = 400,
        rewards = {
            tome = "very rare",
            experience = 840000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                royalHelmet = {
                    id = 2498,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19010,
        task_name = "Frost Dragons",
        monster_names = {"Frost Dragon"},
        count = 200,
        rewards = {
            tome = "very rare",
            experience = 420000,
            points = 5,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                dragonSlayer = {
                    id = 7402,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19011,
        task_name = "Sea serpents",
        monster_names = {"Sea Serpent", "Young Sea Serpent"},
        count = 400,
        rewards = {
            tome = "very rare",
            experience = 1320000,
            points = 4,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 1
                },
                crystallineArmor = {
                    id = 8878,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19012,
        task_name = "Warlocks",
        monster_names = {"Warlock", "Infernalist"},
        count = 150,
        rewards = {
            tome = "very rare",
            experience = 600000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 3
                },
                ringOfTheSky = {
                    id = 2123,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19013,
        task_name = "Behemoths",
        monster_names = {"Behemoth"},
        count = 500,
        rewards = {
            tome = "very rare",
            experience = 1250000,
            points = 6,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 3
                },
                steelBoots = {
                    id = 2645,
                    amount = 1
                },
                behemothFang = {
                    id = 5893,
                    amount = 10
                },
                behemothTrophy = {
                    id = 7396,
                    amount = 1
                }
            }
        }
    },
    {
        id = 19014,
        task_name = "Demons",
        monster_names = {"Demon"},
        count = 500,
        rewards = {
            tome = "very epic",
            experience = 3000000,
            points = 15,
            items = {
                crystalCoins = {
                    id = 2160,
                    amount = 10
                },
                mms = {
                    id = 2514,
                    amount = 1
                },
                demonTrophy = {
                    id = 7393,
                    amount = 1
                }
            }
        }
    }
}

task_point_id = 19090

point_tresholds = {5, 25, 50, 100}

skinning_door_id = 19091
skinning_chest_id = 19191
khajit_door_aid = 19092
tp_door_aid = 19093
primal_door_aid = 19094
moon_backpack_chest_uid = 19195

function getTask(monsterName)
    for _, task in ipairs(monster_tasks) do
        for _, name in ipairs(task.monster_names) do
            if name == monsterName then
                return task
            end
        end
    end

    return nil
end

local function updatePlayerProgress(player, task)
    local killCount = player:getStorageValue(task.id)
    if killCount < task.count then
        local newKillCount = killCount + 1
        player:setStorageValue(task.id, newKillCount)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You have killed " .. newKillCount .. " out of " .. task.count .. " " .. task.task_name)
   
        if newKillCount == task.count then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Congratulations you have finished the task! Talk to Bear Grylls to claim your reward.")
        end
    end
end

local function shouldGetReward(participant, killer)
    if participant:getName() == killer:getName() then
        return true
    end

    local party = killer:getParty()
    if party and party:getMemberCount() > 0 then
        local partyMembers = party:getMembers()
        local leader = party:getLeader()
        for _, member in ipairs(partyMembers) do
            if participant == member or participant == leader then
                return true
            end
        end
    end

    return false
end

local task_monster_kill = CreatureEvent("task_monster_kill")

function task_monster_kill.onKill(killer, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end

    local monsterName = target:getName()
    local task = getTask(monsterName)

    if task == nil then
        return true
    end

    for cid, _ in pairs(target:getDamageMap()) do
        local participant = Player(cid)
        if participant ~= nil and shouldGetReward(participant, killer) then
            updatePlayerProgress(participant, task)
        end
    end

    return true
end

task_monster_kill:register()

local login = CreatureEvent("register_task_monster_kill")

function login.onLogin(player)

    for _, task in ipairs(monster_tasks) do
        if player:getStorageValue(task.id) == -1 then
            player:setStorageValue(task.id, 0)
        end
    end

    if player:getStorageValue(task_point_id) == -1 then
        player:setStorageValue(task_point_id, 0)
    end

    if player:getAccountStorageValue(tp_door_aid) == 1 and player:getStorageValue(tp_door_aid) ~= 1 then
        player:setStorageValue(tp_door_aid, 1)
    end  

    player:registerEvent("task_monster_kill")
    return true
end

login:register()

function compareTasks(a,b)
    return a.task_name < b.task_name
end

local talkAction = TalkAction("!tasks", "!task")

function talkAction.onSay(player, words, param)
    local points = player:getStorageValue(task_point_id)
   
    local text = "Points: " .. points .. "\n"

    table.sort(monster_tasks, compareTasks)
    for _, task in ipairs(monster_tasks) do
        local killCount = player:getStorageValue(task.id)
        text = string.format("%s \n%s: %i out of %i", text, task.task_name, killCount, task.count)
    end

    player:showTextDialog(1952, text)
    return false
end

talkAction:register()


npc/scripts - task_npc.lua
Lua:
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

npcHandler:setMessage(MESSAGE_GREET, "Hello there |PLAYERNAME|! Have you completed a {task}? Want to {trade} leather? Do you want to know how many {points} you got?")

local function rewardItems(player, rewards)
--[[    if rewards.tome then
        for _, book in ipairs(tierBooks) do
            if book.t == rewards.tome then
                local tome = Game.createItem(book.id, 1)
                enableBooks(tome)
                player:addItemEx(tome, true)
                player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got a " .. book.t .. " book!")
            end              
        end
    end You can ignore this bit-- ]]

    for _, item in pairs(rewards.items) do
        local newItem = Game.createItem(item.id, item.amount)
        local itemType = ItemType(item.id)

        if item.amount > 1 then
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. item.amount .. " " .. newItem:getPluralName() .. ".")
        else
            local rarity = rollRareOrEpic()
            if rollRarity(newItem, rarity, true) > 0 then
                local articles = newItem:getArticle():splitTrimmed(" ")
                local rolledRarity = #articles > 1 and articles[2] or articles[1]

                player:getPosition():sendMagicEffect(CONST_ME_STUN)
                local spectators = Game.getSpectators(player:getPosition(), false, true, 7, 7, 5, 5)
                for i = 1, #spectators do
                    spectators[i]:say(rolledRarity, TALKTYPE_MONSTER_SAY, false, spectators[i], player:getPosition())
                end
            end
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. newItem:getArticle() .. " " .. itemType:getName() .. ".")
        end
        player:addItemEx(newItem, true)
    end
end

local function rewardPoints(player, points)
    local pointsBefore = player:getStorageValue(task_point_id)
    local pointsAfter = pointsBefore + points

    local newTreshold = false

    for key, treshold in ipairs(point_tresholds) do
        if pointsBefore < treshold and pointsAfter >= treshold then
            newTreshold = key
            --Give access to new door
            if key == 1 then
                player:setStorageValue(skinning_door_id, 1)

            elseif key == 2 then
                player:setStorageValue(khajit_door_aid, 1)

            elseif key == 4 then
                player:setStorageValue(primal_door_aid, 1)
            end
        end
    end

    player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You got " .. points .. " task points. You now have " .. pointsAfter .. " task points.")

    player:setStorageValue(task_point_id, pointsAfter)
    return newTreshold
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 player = Player(cid)

    if msgcontains(msg, "task") then
        local completedTask = nil

        for _, task in ipairs(monster_tasks) do
            local killCount = player:getStorageValue(task.id)
            if killCount >= task.count then
                completedTask = task
                break
            end
        end

        if completedTask == nil then
            selfSay("I will reward you with items, experience and task {points} if you kill enough of certain monsters. Type !tasks to check your current progress.", cid)
        else
            selfSay("Impressive! Here, take your reward for completing the " .. completedTask.task_name .. " task.", cid)
            local rewards = completedTask.rewards
            player:addExperience(rewards.experience, true)

            local reachedTreshold = rewardPoints(player, rewards.points)

            if reachedTreshold then
                if reachedTreshold == 3 then
                    if player:getAccountStorageValue(tp_door_aid) ~= 1 then
                        player:setAccountStorageValue(tp_door_aid, 1)
                        player:setStorageValue(tp_door_aid, 1)
                        selfSay("Congratulations! You reached a new rank. You and all of your characters now access my special teleport room downstairs.", cid)
                    else
                        selfSay("Congratulations! You reached a new rank. Unfortunately you have already received the reward for this rank on another character.", cid)
                    end
                else
                    selfSay("Congratulations! You reached a new rank. You now access another one of my doors downstairs.", cid)
                end
            else

            end

            rewardItems(player, rewards)

            player:setStorageValue(completedTask.id, 0)
        end
    elseif msgcontains(msg, "point") then
        local points = player:getStorageValue(task_point_id)
        selfSay("You get rewarded with task points depending on the difficulty of the task completed.\nA new door in the basement unlocks at 5, 25, 50, 100 points.\nYou currently have " .. points .. " task points.", cid)
    end

    return true
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'minotaur leather'}, 5878, 10000, 'minotaur leather')
shopModule:addBuyableItem({'lizard leather'}, 5876, 10000, 'lizard leather')
shopModule:addBuyableItem({'green dragon leather'}, 5877, 15000, 'green dragon leather')
shopModule:addBuyableItem({'red dragon leather'}, 5948, 20000, 'red dragon leather')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thanks :D
 
Back
Top