<?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 = 100,exp = 10000,money = 2000},
["goblins"] = {monster_race={"goblin","goblin assassin","goblin leader"}, storage_site = 800202,storage_start = 200201, storage_start = 200202, storage = 91002,count = 100,exp = 10000,money = 2000},
["rotworms"] = {monster_race={"rotworm","carrion worm"}, storage_site = 800203, storage_start = 200203, storage = 91003,count = 150,exp = 15500,money = 2000},
["cyclops"] = {monster_race={"cyclops","cyclops smith","cyclops drone"}, storage_site = 800204, storage_start = 200204, storage = 91004,count = 500,exp = 150000, money = 10000},
["dwarf guards"] = {monster_race={"dwarf guard"}, storage_site = 800205, storage_start = 200205, storage = 91005,count = 500,exp = 200000, money = 15000},
["orc warlords"] = {monster_race={"orc warlord"}, storage_site = 800206, storage_start = 200248, storage = 91048,count = 250,exp = 18000},
["dwarfs"] = {monster_race={"dwarf guard","dwarf","dwarf soldier"}, storage_site = 800207, storage_start = 200249, storage = 91049, count = 250, exp = 30000, money = 2000},
["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 = 150,exp = 10000,money = 3000},
["tarantulas"] = {monster_race={"tarantula"}, storage_site = 800209, storage_start = 200207, storage = 91007,count = 200,exp = 55000,money = 5000},
["demon skeletons"] = {monster_race={"demon skeleton"}, storage_site = 800210, storage_start = 200208, storage = 91008,count = 200,exp = 120000},
["minotaurs"] = {monster_race={"minotaur","minotaur archer","minotaur mage","minotaur guard"}, storage_site = 800211, storage_start = 200209, storage = 91009,count = 500,exp = 75000,money = 10000},
["necromancers"] = {monster_race={"necromancer","priestess"}, storage_site = 800212, storage_start = 200210, storage = 91010,count= 350, exp = 350000, reward = {{2195,1}}},
["carniphilas"] = {monster_race={"carniphila"}, storage_site = 800213, storage_start = 200211, storage = 91011,count= 75, exp = 35000},
["apes"] = {monster_race={"kongra","sibang","merlkin"}, storage_site = 800214, storage_start = 200212, storage = 91012,count= 450, exp = 200000, money = 10000},
["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= 500, exp = 350000, 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 = 350, exp = 350000, money = 20000},
["hydras"] = {monster_race={"hydra"}, storage_site = 800219, storage_start = 200217, storage = 91017,count = 350, exp = 850000},
["serpent spawns"] = {monster_race={"serpent spawn"}, storage_site = 800220, storage_start = 200218, storage = 91018,count = 350, exp = 930000},
["behemoths"] = {monster_race={"behemoth"}, storage_site = 800221, storage_start = 200219, storage = 91019,count = 500, exp = 950000},
["crocodiles"] = {monster_race={"crocodile"}, storage_site = 800222, storage_start = 200220, storage = 91020,count = 150, exp = 11000, money = 2500},
["demons"] = {monster_race={"demon"}, storage_site = 800223, storage_start = 200221, storage = 91021,count = 666, exp = 1900000},
["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 = 200, exp = 20000, money = 2000},
["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 = 50000, money = 15000},
["scarabs"] = {monster_race={"scarab","ancient scarab"}, storage_site = 800227, storage_start = 200225, storage = 91025,count = 300, exp = 55000, money = 5000},
["vampires"] = {monster_race={"vampire"}, storage_site = 800228, storage_start = 200226, storage = 91026,count = 500, exp = 350000, reward = {{2534,1}}},
["ancient scarabs"] = {monster_race={"ancient scarab"}, storage_site = 800229, storage_start = 200227, storage = 91027,count = 300, exp = 300000, money = 15000},
["heros"] = {monster_race={"hero"}, storage_site = 800230, storage_start = 200228, storage = 91028,count = 100, exp = 250000, reward = {{2488,1}}},
["black knights"] = {monster_race={"black knight"}, storage_site = 800231, storage_start = 200229, storage = 91029,count = 50, exp = 250000, reward = {{2414,1}}},
["dragon lords"] = {monster_race={"dragon lord"}, storage_site = 800232, storage_start = 200230, storage = 91030,count = 550, exp = 850000},
["warlocks"] = {monster_race={"warlock"}, storage_site = 800233, storage_start = 200231, storage = 91031,count = 400, exp = 1100000},
["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 = 60000,money = 5000},
["lizards"] = {monster_race={"lizard sentinel","lizard snakecharmer","lizard templar"}, storage_site = 800251, storage_start = 200251, storage = 91051,count = 450, exp = 105000,money = 10000},
["orc berserkers"] = {monster_race={"orc berserker"}, storage_site = 800252, storage_start = 200252, storage = 91052,count = 350, exp = 95000,money = 5000},
["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, onKill)
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>