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

DailyTask ~100%

adric21

Well-Known Member
Joined
Apr 26, 2016
Messages
277
Solutions
1
Reaction score
72
Go to / data / npc and create the daily.xml file, open it and put it all in there:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tian" walkinterval="2000" floorchange="0" script="dailyTask.lua">
    <health now="100" max="100"/>
    <look type="128" head="0" body="112" legs="107" feet="113" addons="0"/>
</npc>

Go to / data / npc / scripts and add the file dailyTask.lua, and inside it put:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(1200, 500, -100)

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local aa, bb, cc, dd, ee, ff = 0
    local player = Player(cid)
        
        if msgcontains(msg, "help") then
            npcHandler:say("I can offer you some {daily tasks}.", cid)
        elseif msgcontains(msg, "task") or msgcontains(msg, "tasks") or msgcontains(msg, "daily") or msgcontains(msg, "tarefa") or  msgcontains(msg, "tarefas") or msgcontains(msg, "diaria") then
            if player:getStorageValue(DT_STORAGES.HAVE_STARTED) > 0 then
                return npcHandler:say("You have already started your daily task today.", cid)
            elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == -2 then
                return npcHandler:say("You have already completed your daily task today.", cid)
            end
            npcHandler:say("I have tasks of level {Easy}, {Medium}, {Hard} and {Expert}. Which one do you want to do?", cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say("What are you talking about??", cid)
        end
        
    if npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "easy") then
        if DT_PREMIOQTDE_EASY > 0 then
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EASY .."}x "..getAllTableText(DT_PRIZENAME_EASY, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        else
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        end
            npcHandler.topic[cid] = 3
        elseif msgcontains(msg, "medium") then
            npcHandler:say("Your MEDIUM daily task today is: Kill {".. DT_NEEDKILL_MEDIUM .."}{ ".. DT_CHOSENTASK_MEDIUM .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_MEDIUM .."}x "..getAllTableText(DT_PRIZENAME_MEDIUM, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_MEDIUM.."}x "..DT_PREMIOFIXO_NAME_MEDIUM..";\n*{"..DT_EXPPRIZE_MEDIUM.."} Experience points;\n*{"..DT_TASKPOINTS_MEDIUM.."}x Task Point.\nDo you want to start this {MEDIUM} task?", cid)
            npcHandler.topic[cid] = 4       
        elseif msgcontains(msg, "hard") then
            npcHandler:say("Your HARD daily task today is: Kill {".. DT_NEEDKILL_HARD .."}{ ".. DT_CHOSENTASK_HARD .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_HARD .."}x "..getAllTableText(DT_PRIZENAME_HARD, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_HARD.."}x "..DT_PREMIOFIXO_NAME_HARD..";\n*{"..DT_EXPPRIZE_HARD.."} Experience points;\n*{"..DT_TASKPOINTS_HARD.."}x Task Point.\nDo you want to start this {HARD} task?", cid)
            npcHandler.topic[cid] = 5       
        elseif msgcontains(msg, "expert") then
            npcHandler:say("Your EXPERT daily task today is: Kill {".. DT_NEEDKILL_EXPERT .." }{".. DT_CHOSENTASK_EXPERT .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EXPERT .."}x "..getAllTableText(DT_PRIZENAME_EXPERT, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EXPERT.."}x "..DT_PREMIOFIXO_NAME_EXPERT..";\n*{"..DT_EXPPRIZE_EXPERT.."} Experience points;\n*{"..DT_TASKPOINTS_EXPERT.."}x Task Point.\nDo you want to start this {EXPERT} task?", cid)
            npcHandler.topic[cid] = 6       
        end
    end
    if msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 3 then   
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EASY, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 1)
        elseif npcHandler.topic[cid] == 4 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.MEDIUM, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 2)
        elseif npcHandler.topic[cid] == 5 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.HARD, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 3)
        elseif npcHandler.topic[cid] == 6 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EXPERT, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 4)
        end       
    end

    if msgcontains(msg, "report") then
        if player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 1 then
            if player:getStorageValue(DT_STORAGES.EASY) >= DT_NEEDKILL_EASY then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
                
                player:addExperience(DT_EXPPRIZE_EASY) --exp
                
                player:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY) --fixo
                if DT_PREMIOQTDE_EASY > 0 then --rand
                    if DT_PREMIOQTDE_EASY == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EASY)
                        player:addItem(DT_PRIZEID_EASY[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EASY) do
                            aa = math.random(#DT_PRIZEID_EASY)
                            player:addItem(DT_PRIZEID_EASY[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EASY - player:getStorageValue(DT_STORAGES.EASY) .."} "..DT_CHOSENTASK_EASY.."(s).", cid)
            end           
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 2 then
            if player:getStorageValue(DT_STORAGES.MEDIUM) >= DT_NEEDKILL_MEDIUM then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
                
                player:addExperience(DT_EXPPRIZE_MEDIUM) --exp
                
                player:addItem(DT_PREMIOFIXO_ID_MEDIUM, DT_PREMIOFIXO_QTDE_MEDIUM) --fixo
                
                if DT_PREMIOQTDE_MEDIUM > 0 then --rand
                    if DT_PREMIOQTDE_MEDIUM == 1 then --rand
                        aa = math.random(#DT_PRIZEID_MEDIUM)
                        player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_MEDIUM) do
                            aa = math.random(#DT_PRIZEID_MEDIUM)
                            player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_MEDIUM - player:getStorageValue(DT_STORAGES.MEDIUM) .."} "..DT_CHOSENTASK_MEDIUM.."(s).", cid)
            end   
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 3 then
            if player:getStorageValue(DT_STORAGES.HARD) >= DT_NEEDKILL_HARD then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
                
                player:addExperience(DT_EXPPRIZE_HARD) --exp
                
                player:addItem(DT_PREMIOFIXO_ID_HARD, DT_PREMIOFIXO_QTDE_HARD) --fixo
                
                if DT_PREMIOQTDE_HARD > 0 then --rand
                    if DT_PREMIOQTDE_HARD == 1 then --rand
                        aa = math.random(#DT_PRIZEID_HARD)
                        player:addItem(DT_PRIZEID_HARD[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_HARD) do
                            aa = math.random(#DT_PRIZEID_HARD)
                            player:addItem(DT_PRIZEID_HARD[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_HARD - player:getStorageValue(DT_STORAGES.HARD) .."} "..DT_CHOSENTASK_HARD.."(s).", cid)
            end   
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 4 then
            if player:getStorageValue(DT_STORAGES.EXPERT) >= DT_NEEDKILL_EXPERT then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
                
                player:addExperience(DT_EXPPRIZE_EXPERT) --exp
                
                player:addItem(DT_PREMIOFIXO_ID_EXPERT, DT_PREMIOFIXO_QTDE_EXPERT) --fixo
                
                if DT_PREMIOQTDE_EXPERT > 0 then --rand
                    if DT_PREMIOQTDE_EXPERT == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EXPERT)
                        player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EXPERT) do
                            aa = math.random(#DT_PRIZEID_EXPERT)
                            player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EXPERT - player:getStorageValue(DT_STORAGES.EXPERT) .."} "..DT_CHOSENTASK_EXPERT.."(s).", cid)
            end   
        else
            npcHandler:say("Uhn.. What are you talking about??", cid)
            npcHandler.topic[cid] = 0
        end
    end
end
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME| i've some {tasks} for u.")
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

In /data/lib/lib.lua, add the line:
Code:
dofile('data/lib/task/dailytask.lua')

Create the dailytask.lua file in / data / lib / task /, and put in:
Code:
-- CONFIGS

local easy = {
minQTDE = 50,
maxQTDE = 300,

minEXP = 250000,
maxEXP = 750000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 0,
maxQTDEPremios = 2,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 1,

taskPoints = 1
}

local medium = {
minQTDE = 100,
maxQTDE = 400,

minEXP = 500000,
maxEXP = 1500000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 1,
maxQTDEPremios = 3,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 2,

taskPoints = 2
}

local hard = {
minQTDE = 150,
maxQTDE = 500,

minEXP = 1000000,
maxEXP = 3000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 2,
maxQTDEPremios = 4,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 3,

taskPoints = 3
}

local expert = {
minQTDE = 200,
maxQTDE = 600,

minEXP = 2000000,
maxEXP = 6000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 3,
maxQTDEPremios = 5,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 4,

taskPoints = 4
}

DT_TasksEasy = {"Minotaur", "Minotaur Guard", "Minotaur Mage", "Minotaur Archer", "Larva", "Scarab", "Wyvern", "Rorc", "Wolf", "War Wolf", "Orc Berserker", "Orc Warrior", "Orc Shaman", "Orc Leader", "Orc", "Cyclops", "Orc Rider", "Slime", "Orc Warlord", "Water Elemental", "Quara Mantassin Scout", "Gargoyle", "Mummy", "Crypt Shambler", "Demon Skeleton", "Ghost", "Zombie", "Rotworm", "Carrion Worm", "Rotworm Queen", "Tortoise", "Thornback Tortoise", "Toad", "Crab", "Blood Crab", "Killer Caiman", "Ghoul", "Scorpion", "Banshee", "Fire Devil", "Amazon", "Valkyrie", "Witch", "Leaf Golem", "Forest Fury", "Troll", "Goblin", "Troll Champion", "Goblin Scavanger", "Goblin Assassin", "Corym Vanguard", "Corym Skirmisher", "Corym Charlatan", "Ghost Wolf", "Gloom Wolf", "Elf", "Elf Arcanist", "Elf Scout", "Firestarter", "Bat", "Swamp Troll", "Stonerefiner", "Tarantula", "Dragon Hatchling", "Nomad", "Scorpion", "Dwarf", "Dwarf Soldier", "Dwarf Guard", "Kongra", "Sibang", "Merlkin", "Gazer", "Bonelord", "Elder Bonelord", "Braindeath"}
DT_TasksMedium = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Cult Believer", "Cult Enforcer", "Cult Scholar", "Ghastly Dragon", "Lizard Chosen", "Giant Spider", "Tarantula", "Bog Raider", "Earth Elemental", "Enfeebled Silencer", "Weakened Frazzlemaw", "Noble Lion", "Ancient Scarab", "Roaring Lion", "Souleater", "Mutated Bat", "Mutated Rat", "Mutated Tiger", "Warlock", "Yielothax", "Killer Caiman", "Vampire Bridge", "Vampire Viscount", "Vampire", "Bonebeast", "Necromancer", "Quara Predator", "Quara Constrictor", "Quara Mantassin", "Quara Pincher", "Quara Hydromancer", "Quara Predator Scout", "Quara Constrictor Scout", "Quara Mantassin Scout", "Quara Pincher Scout", "Quara Hydromancer Scout", "Wyrm", "Behemoth", "Nightstalker", "Giant Spider", "Energy Elemental", "Stampor", "Bonebeast", "Orc Cult Inquisitor", "Orc Cult Minion", "Orc Cultist", "Orc Cult Priest", "Orc Cult Fanatic", "Lost Husher", "Lost Basher", "Lost Thrower", "enslaved Dwarf", "Dragon", "Dragon Lord", "Barkless Devotee", "Barkless Fanatic", "Massive Water Elemental", "Minotaur Cult Follower", "Minotaur Cult Prophet", "Minotaur Cult Zealot" }
DT_TasksHard = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Hero", "Necromancer", "Lich", "Werebear", "Wereboar", "Werebadger", "Werewolf", "Askarak Demon", "Shaburak Demon", "Wyrm", "Elder Wyrm", "Vampire Viscount", "Blood Priest", "Shadow Pupil", "White Shade", "Vampire", "Putrid Mummy", "Giant Spider", "Fury", "Massive Fire Elemental", "Dragonling", "Hellfire Fighter", "Diabolic Imp", "Hellhound", "Infernalist", "Behemoth", "Dawnfire Asura", "Midnight Asura", "Hellspawn", "Plaguesmith", "Medusa", "Serpent Spawn", "Hydra", "Dark Faun", "Boogy", "Twisted Pooka", "Draken Elite", "Draken Warmaster", "Draken Spellweaver", "Draken Abomination", "Lizard Legionnaire", "Lizard Dragon Priest", "Lizard High Guard", "Lizard Chosen", "Ghastly Dragon"}
DT_TasksExpert = {"Guzzlemaw", "Sight of Surrender", "Terrorsleep", "Silencer", "Dark Torturer", "Demon Outcast", "Betrayed Wraith", "Plaguesmith", "Blightwalker", "Nightmare", "Juggernault", "Hellhound", "Crazed Winter Rearguard", "Crazed Winter Vanguard", "Crazed Summer Rearguard", "Crazed Summer Vanguard", "Spiky Carnivor", "Lumbering Carnivor", "Menacing Carnivor", "Vexclaw", "Grimeleech", "Demon", "Hellflayer", "Hellfire Fighter", "Fury", "Undead Dragon", "Phantasm", "Nightmare", "Defiler", "Plaguesmith", "Spectre", "Hand of Cursed Fate", "Undead Elite Gladiator", "Skeleton Elite Warrior", "Grim Reaper", "Gravedigger", "Floating Servant", "Lava Luker Attendant", "Cobra Assassin", "Cobra Vizier", "Cobra Scout", "Dread Intruder", "Reality Reaver", "Sparkion", "Breach Brood", "Choking Fear", "Retching Horror", "Animated Feather", "Biting Book", "Brain Squid", "Burning Book", "Cursed Book", "Energetic Book", "Energuardian of Tales", "Flying Book", "Guardian of Tales", "Icecold Book", "Ink Blob", "Knowledge Elemental", "Rage Squid", "Squid Warden", "Lost Soul", "Falcon Knight", "Falcon Paladin"}

-- SCRIPT

    
    DT_STORAGES = {
        PONTOS = 367643975,
        EXPERT = 367643974,
        HARD = 367643973,
        MEDIUM = 367643972,
        EASY = 367643971,
        HAVE_STARTED = 367643970,
            }
            
    --RESETAR STORAGES
        for i = 1, 6 do
        db.query('DELETE FROM `player_storage` WHERE `player_storage`.`key` = '.. 367643969+i ..'')
        end   
        
    -- EASY (100-)
        DT_CHOSENTASK_EASY = DT_TasksEasy[math.random(#DT_TasksEasy)]
        DT_NEEDKILL_EASY = math.ceil(math.random(easy.minQTDE, easy.maxQTDE))
        DT_EXPPRIZE_EASY = math.random(easy.minEXP, easy.maxEXP)
        
        DT_PRIZEID_EASY = easy.prizesID
        DT_PRIZENAME_EASY = easy.prizesNAME
        DT_PREMIOQTDE_EASY = math.random(easy.minQTDEPremios, easy.maxQTDEPremios)
        
        DT_PREMIOFIXO_ID_EASY = easy.PremioFixoID
        DT_PREMIOFIXO_NAME_EASY = easy.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EASY = easy.PremioFixoQTDE
        
        DT_TASKPOINTS_EASY = easy.taskPoints
        
    -- MEDIUM (150-)
        DT_CHOSENTASK_MEDIUM = DT_TasksMedium[math.random(#DT_TasksMedium)]
        DT_NEEDKILL_MEDIUM = math.ceil(math.random(medium.minQTDE, medium.maxQTDE))
        DT_EXPPRIZE_MEDIUM = math.random(medium.minEXP, medium.maxEXP)
        
        DT_PRIZEID_MEDIUM = medium.prizesID
        DT_PRIZENAME_MEDIUM = medium.prizesNAME
        DT_PREMIOQTDE_MEDIUM = math.random(medium.minQTDEPremios, medium.maxQTDEPremios)
        
        DT_PREMIOFIXO_ID_MEDIUM = medium.PremioFixoID
        DT_PREMIOFIXO_NAME_MEDIUM = medium.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_MEDIUM = medium.PremioFixoQTDE
        
        DT_TASKPOINTS_MEDIUM = medium.taskPoints
    
    --HARD (200-)
        DT_CHOSENTASK_HARD = DT_TasksHard[math.random(#DT_TasksHard)]
        DT_NEEDKILL_HARD = math.ceil(math.random(hard.minQTDE, hard.maxQTDE))
        DT_EXPPRIZE_HARD = math.random(hard.minEXP, hard.maxEXP)
        
        DT_PRIZEID_HARD = hard.prizesID
        DT_PRIZENAME_HARD = hard.prizesNAME
        DT_PREMIOQTDE_HARD = math.random(hard.minQTDEPremios, hard.maxQTDEPremios)
        
        DT_PREMIOFIXO_ID_HARD = hard.PremioFixoID
        DT_PREMIOFIXO_NAME_HARD = hard.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_HARD = hard.PremioFixoQTDE
        
        DT_TASKPOINTS_HARD = hard.taskPoints
        
    --EXPERT (200+)
        DT_CHOSENTASK_EXPERT = DT_TasksExpert[math.random(#DT_TasksExpert)]
        DT_NEEDKILL_EXPERT = math.ceil(math.random(expert.minQTDE, expert.maxQTDE))
        DT_EXPPRIZE_EXPERT = math.random(expert.minEXP, expert.maxEXP)
        
        DT_PRIZEID_EXPERT = expert.prizesID
        DT_PRIZENAME_EXPERT = expert.prizesNAME
        DT_PREMIOQTDE_EXPERT = math.random(expert.minQTDEPremios, expert.maxQTDEPremios)
        
        DT_PREMIOFIXO_ID_EXPERT = expert.PremioFixoID
        DT_PREMIOFIXO_NAME_EXPERT = expert.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EXPERT = expert.PremioFixoQTDE
        
        DT_TASKPOINTS_EXPERT = expert.taskPoints

        -- FUNÇÃO PRA PEGAR OS NOMES DOS ITEM
function getAllTableText(aa, bb, cc)
local tablecheck = aa

if not tablecheck then
    return false
end

local lang = bb
local ponto = ""
if not lang then
    lang = "and"
end
if cc then
ponto = "."
end
local text = ""
for i = 1, #tablecheck do
    if i == 1 then
    text = tablecheck[i]
    elseif i == #tablecheck then
    text = text .." "..lang.." "..tablecheck[i]..""..ponto..""
    else
    text = text ..", "..tablecheck[i]
    end
end
return text
end


In /data/creaturescript/creaturescripts.xml add the tag:
Code:
<event type="kill" name="dailyTasks" script="dailyTasks.lua"/>

Register the "dailyTasks" in your login.lua


Create the dailyTasks.lua file in / data / creaturescript / scripts and put it all inside:
Code:
function onKill(player, target)
local monster = getCreatureName(target)
    
local KILL_EASY = player:getStorageValue(DT_STORAGES.EASY)
local KILL_MEDIUM = player:getStorageValue(DT_STORAGES.MEDIUM)
local KILL_HARD = player:getStorageValue(DT_STORAGES.HARD)
local KILL_EXPERT = player:getStorageValue(DT_STORAGES.EXPERT)

local isDOING = player:getStorageValue(DT_STORAGES.HAVE_STARTED)

if isDOING == 1 then
    if monster:lower() == DT_CHOSENTASK_EASY:lower() then
                player:setStorageValue(DT_STORAGES.EASY, KILL_EASY + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EASY-KILL_EASY-1 .." to kill.")
        end
    end
elseif isDOING == 2 then
    if monster:lower() == DT_CHOSENTASK_MEDIUM:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_MEDIUM + 1)
        if KILL_MEDIUM >= DT_NEEDKILL_MEDIUM then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_MEDIUM.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_MEDIUM-KILL_MEDIUM-1 .." to kill.")       
        end
    end
elseif isDOING == 3 then
    if monster:lower() == DT_CHOSENTASK_HARD:lower() then
                player:setStorageValue(DT_STORAGES.HARD, KILL_HARD + 1)
        if KILL_HARD >= DT_NEEDKILL_HARD then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_HARD.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_HARD-KILL_HARD-1 .." to kill.")       
        end
    end
elseif isDOING == 4 then
    if monster:lower() == DT_CHOSENTASK_EXPERT:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_EXPERT + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EXPERT-KILL_EXPERT-1 .." to kill.")       
        end
    end
end

return true
end

:)
 
Just remember add the tag of Login.lua
 
Someone explain me why he adds damage condition for a npc
Lua:
local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(1200, 500, -100)

I dont know maybe im just unskilled
 
Go to / data / npc and create the daily.xml file, open it and put it all in there:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tian" walkinterval="2000" floorchange="0" script="dailyTask.lua">
    <health now="100" max="100"/>
    <look type="128" head="0" body="112" legs="107" feet="113" addons="0"/>
</npc>

Go to / data / npc / scripts and add the file dailyTask.lua, and inside it put:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(1200, 500, -100)

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local aa, bb, cc, dd, ee, ff = 0
    local player = Player(cid)
       
        if msgcontains(msg, "help") then
            npcHandler:say("I can offer you some {daily tasks}.", cid)
        elseif msgcontains(msg, "task") or msgcontains(msg, "tasks") or msgcontains(msg, "daily") or msgcontains(msg, "tarefa") or  msgcontains(msg, "tarefas") or msgcontains(msg, "diaria") then
            if player:getStorageValue(DT_STORAGES.HAVE_STARTED) > 0 then
                return npcHandler:say("You have already started your daily task today.", cid)
            elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == -2 then
                return npcHandler:say("You have already completed your daily task today.", cid)
            end
            npcHandler:say("I have tasks of level {Easy}, {Medium}, {Hard} and {Expert}. Which one do you want to do?", cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say("What are you talking about??", cid)
        end
       
    if npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "easy") then
        if DT_PREMIOQTDE_EASY > 0 then
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EASY .."}x "..getAllTableText(DT_PRIZENAME_EASY, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        else
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        end
            npcHandler.topic[cid] = 3
        elseif msgcontains(msg, "medium") then
            npcHandler:say("Your MEDIUM daily task today is: Kill {".. DT_NEEDKILL_MEDIUM .."}{ ".. DT_CHOSENTASK_MEDIUM .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_MEDIUM .."}x "..getAllTableText(DT_PRIZENAME_MEDIUM, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_MEDIUM.."}x "..DT_PREMIOFIXO_NAME_MEDIUM..";\n*{"..DT_EXPPRIZE_MEDIUM.."} Experience points;\n*{"..DT_TASKPOINTS_MEDIUM.."}x Task Point.\nDo you want to start this {MEDIUM} task?", cid)
            npcHandler.topic[cid] = 4      
        elseif msgcontains(msg, "hard") then
            npcHandler:say("Your HARD daily task today is: Kill {".. DT_NEEDKILL_HARD .."}{ ".. DT_CHOSENTASK_HARD .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_HARD .."}x "..getAllTableText(DT_PRIZENAME_HARD, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_HARD.."}x "..DT_PREMIOFIXO_NAME_HARD..";\n*{"..DT_EXPPRIZE_HARD.."} Experience points;\n*{"..DT_TASKPOINTS_HARD.."}x Task Point.\nDo you want to start this {HARD} task?", cid)
            npcHandler.topic[cid] = 5      
        elseif msgcontains(msg, "expert") then
            npcHandler:say("Your EXPERT daily task today is: Kill {".. DT_NEEDKILL_EXPERT .." }{".. DT_CHOSENTASK_EXPERT .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EXPERT .."}x "..getAllTableText(DT_PRIZENAME_EXPERT, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EXPERT.."}x "..DT_PREMIOFIXO_NAME_EXPERT..";\n*{"..DT_EXPPRIZE_EXPERT.."} Experience points;\n*{"..DT_TASKPOINTS_EXPERT.."}x Task Point.\nDo you want to start this {EXPERT} task?", cid)
            npcHandler.topic[cid] = 6      
        end
    end
    if msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 3 then  
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EASY, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 1)
        elseif npcHandler.topic[cid] == 4 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.MEDIUM, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 2)
        elseif npcHandler.topic[cid] == 5 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.HARD, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 3)
        elseif npcHandler.topic[cid] == 6 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EXPERT, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 4)
        end      
    end

    if msgcontains(msg, "report") then
        if player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 1 then
            if player:getStorageValue(DT_STORAGES.EASY) >= DT_NEEDKILL_EASY then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_EASY) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY) --fixo
                if DT_PREMIOQTDE_EASY > 0 then --rand
                    if DT_PREMIOQTDE_EASY == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EASY)
                        player:addItem(DT_PRIZEID_EASY[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EASY) do
                            aa = math.random(#DT_PRIZEID_EASY)
                            player:addItem(DT_PRIZEID_EASY[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EASY - player:getStorageValue(DT_STORAGES.EASY) .."} "..DT_CHOSENTASK_EASY.."(s).", cid)
            end          
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 2 then
            if player:getStorageValue(DT_STORAGES.MEDIUM) >= DT_NEEDKILL_MEDIUM then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_MEDIUM) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_MEDIUM, DT_PREMIOFIXO_QTDE_MEDIUM) --fixo
               
                if DT_PREMIOQTDE_MEDIUM > 0 then --rand
                    if DT_PREMIOQTDE_MEDIUM == 1 then --rand
                        aa = math.random(#DT_PRIZEID_MEDIUM)
                        player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_MEDIUM) do
                            aa = math.random(#DT_PRIZEID_MEDIUM)
                            player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_MEDIUM - player:getStorageValue(DT_STORAGES.MEDIUM) .."} "..DT_CHOSENTASK_MEDIUM.."(s).", cid)
            end  
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 3 then
            if player:getStorageValue(DT_STORAGES.HARD) >= DT_NEEDKILL_HARD then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_HARD) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_HARD, DT_PREMIOFIXO_QTDE_HARD) --fixo
               
                if DT_PREMIOQTDE_HARD > 0 then --rand
                    if DT_PREMIOQTDE_HARD == 1 then --rand
                        aa = math.random(#DT_PRIZEID_HARD)
                        player:addItem(DT_PRIZEID_HARD[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_HARD) do
                            aa = math.random(#DT_PRIZEID_HARD)
                            player:addItem(DT_PRIZEID_HARD[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_HARD - player:getStorageValue(DT_STORAGES.HARD) .."} "..DT_CHOSENTASK_HARD.."(s).", cid)
            end  
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 4 then
            if player:getStorageValue(DT_STORAGES.EXPERT) >= DT_NEEDKILL_EXPERT then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_EXPERT) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_EXPERT, DT_PREMIOFIXO_QTDE_EXPERT) --fixo
               
                if DT_PREMIOQTDE_EXPERT > 0 then --rand
                    if DT_PREMIOQTDE_EXPERT == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EXPERT)
                        player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EXPERT) do
                            aa = math.random(#DT_PRIZEID_EXPERT)
                            player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EXPERT - player:getStorageValue(DT_STORAGES.EXPERT) .."} "..DT_CHOSENTASK_EXPERT.."(s).", cid)
            end  
        else
            npcHandler:say("Uhn.. What are you talking about??", cid)
            npcHandler.topic[cid] = 0
        end
    end
end
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME| i've some {tasks} for u.")
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

In /data/lib/lib.lua, add the line:
Code:
dofile('data/lib/task/dailytask.lua')

Create the dailytask.lua file in / data / lib / task /, and put in:
Code:
-- CONFIGS

local easy = {
minQTDE = 50,
maxQTDE = 300,

minEXP = 250000,
maxEXP = 750000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 0,
maxQTDEPremios = 2,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 1,

taskPoints = 1
}

local medium = {
minQTDE = 100,
maxQTDE = 400,

minEXP = 500000,
maxEXP = 1500000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 1,
maxQTDEPremios = 3,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 2,

taskPoints = 2
}

local hard = {
minQTDE = 150,
maxQTDE = 500,

minEXP = 1000000,
maxEXP = 3000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 2,
maxQTDEPremios = 4,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 3,

taskPoints = 3
}

local expert = {
minQTDE = 200,
maxQTDE = 600,

minEXP = 2000000,
maxEXP = 6000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 3,
maxQTDEPremios = 5,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 4,

taskPoints = 4
}

DT_TasksEasy = {"Minotaur", "Minotaur Guard", "Minotaur Mage", "Minotaur Archer", "Larva", "Scarab", "Wyvern", "Rorc", "Wolf", "War Wolf", "Orc Berserker", "Orc Warrior", "Orc Shaman", "Orc Leader", "Orc", "Cyclops", "Orc Rider", "Slime", "Orc Warlord", "Water Elemental", "Quara Mantassin Scout", "Gargoyle", "Mummy", "Crypt Shambler", "Demon Skeleton", "Ghost", "Zombie", "Rotworm", "Carrion Worm", "Rotworm Queen", "Tortoise", "Thornback Tortoise", "Toad", "Crab", "Blood Crab", "Killer Caiman", "Ghoul", "Scorpion", "Banshee", "Fire Devil", "Amazon", "Valkyrie", "Witch", "Leaf Golem", "Forest Fury", "Troll", "Goblin", "Troll Champion", "Goblin Scavanger", "Goblin Assassin", "Corym Vanguard", "Corym Skirmisher", "Corym Charlatan", "Ghost Wolf", "Gloom Wolf", "Elf", "Elf Arcanist", "Elf Scout", "Firestarter", "Bat", "Swamp Troll", "Stonerefiner", "Tarantula", "Dragon Hatchling", "Nomad", "Scorpion", "Dwarf", "Dwarf Soldier", "Dwarf Guard", "Kongra", "Sibang", "Merlkin", "Gazer", "Bonelord", "Elder Bonelord", "Braindeath"}
DT_TasksMedium = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Cult Believer", "Cult Enforcer", "Cult Scholar", "Ghastly Dragon", "Lizard Chosen", "Giant Spider", "Tarantula", "Bog Raider", "Earth Elemental", "Enfeebled Silencer", "Weakened Frazzlemaw", "Noble Lion", "Ancient Scarab", "Roaring Lion", "Souleater", "Mutated Bat", "Mutated Rat", "Mutated Tiger", "Warlock", "Yielothax", "Killer Caiman", "Vampire Bridge", "Vampire Viscount", "Vampire", "Bonebeast", "Necromancer", "Quara Predator", "Quara Constrictor", "Quara Mantassin", "Quara Pincher", "Quara Hydromancer", "Quara Predator Scout", "Quara Constrictor Scout", "Quara Mantassin Scout", "Quara Pincher Scout", "Quara Hydromancer Scout", "Wyrm", "Behemoth", "Nightstalker", "Giant Spider", "Energy Elemental", "Stampor", "Bonebeast", "Orc Cult Inquisitor", "Orc Cult Minion", "Orc Cultist", "Orc Cult Priest", "Orc Cult Fanatic", "Lost Husher", "Lost Basher", "Lost Thrower", "enslaved Dwarf", "Dragon", "Dragon Lord", "Barkless Devotee", "Barkless Fanatic", "Massive Water Elemental", "Minotaur Cult Follower", "Minotaur Cult Prophet", "Minotaur Cult Zealot" }
DT_TasksHard = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Hero", "Necromancer", "Lich", "Werebear", "Wereboar", "Werebadger", "Werewolf", "Askarak Demon", "Shaburak Demon", "Wyrm", "Elder Wyrm", "Vampire Viscount", "Blood Priest", "Shadow Pupil", "White Shade", "Vampire", "Putrid Mummy", "Giant Spider", "Fury", "Massive Fire Elemental", "Dragonling", "Hellfire Fighter", "Diabolic Imp", "Hellhound", "Infernalist", "Behemoth", "Dawnfire Asura", "Midnight Asura", "Hellspawn", "Plaguesmith", "Medusa", "Serpent Spawn", "Hydra", "Dark Faun", "Boogy", "Twisted Pooka", "Draken Elite", "Draken Warmaster", "Draken Spellweaver", "Draken Abomination", "Lizard Legionnaire", "Lizard Dragon Priest", "Lizard High Guard", "Lizard Chosen", "Ghastly Dragon"}
DT_TasksExpert = {"Guzzlemaw", "Sight of Surrender", "Terrorsleep", "Silencer", "Dark Torturer", "Demon Outcast", "Betrayed Wraith", "Plaguesmith", "Blightwalker", "Nightmare", "Juggernault", "Hellhound", "Crazed Winter Rearguard", "Crazed Winter Vanguard", "Crazed Summer Rearguard", "Crazed Summer Vanguard", "Spiky Carnivor", "Lumbering Carnivor", "Menacing Carnivor", "Vexclaw", "Grimeleech", "Demon", "Hellflayer", "Hellfire Fighter", "Fury", "Undead Dragon", "Phantasm", "Nightmare", "Defiler", "Plaguesmith", "Spectre", "Hand of Cursed Fate", "Undead Elite Gladiator", "Skeleton Elite Warrior", "Grim Reaper", "Gravedigger", "Floating Servant", "Lava Luker Attendant", "Cobra Assassin", "Cobra Vizier", "Cobra Scout", "Dread Intruder", "Reality Reaver", "Sparkion", "Breach Brood", "Choking Fear", "Retching Horror", "Animated Feather", "Biting Book", "Brain Squid", "Burning Book", "Cursed Book", "Energetic Book", "Energuardian of Tales", "Flying Book", "Guardian of Tales", "Icecold Book", "Ink Blob", "Knowledge Elemental", "Rage Squid", "Squid Warden", "Lost Soul", "Falcon Knight", "Falcon Paladin"}

-- SCRIPT

   
    DT_STORAGES = {
        PONTOS = 367643975,
        EXPERT = 367643974,
        HARD = 367643973,
        MEDIUM = 367643972,
        EASY = 367643971,
        HAVE_STARTED = 367643970,
            }
           
    --RESETAR STORAGES
        for i = 1, 6 do
        db.query('DELETE FROM `player_storage` WHERE `player_storage`.`key` = '.. 367643969+i ..'')
        end  
       
    -- EASY (100-)
        DT_CHOSENTASK_EASY = DT_TasksEasy[math.random(#DT_TasksEasy)]
        DT_NEEDKILL_EASY = math.ceil(math.random(easy.minQTDE, easy.maxQTDE))
        DT_EXPPRIZE_EASY = math.random(easy.minEXP, easy.maxEXP)
       
        DT_PRIZEID_EASY = easy.prizesID
        DT_PRIZENAME_EASY = easy.prizesNAME
        DT_PREMIOQTDE_EASY = math.random(easy.minQTDEPremios, easy.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_EASY = easy.PremioFixoID
        DT_PREMIOFIXO_NAME_EASY = easy.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EASY = easy.PremioFixoQTDE
       
        DT_TASKPOINTS_EASY = easy.taskPoints
       
    -- MEDIUM (150-)
        DT_CHOSENTASK_MEDIUM = DT_TasksMedium[math.random(#DT_TasksMedium)]
        DT_NEEDKILL_MEDIUM = math.ceil(math.random(medium.minQTDE, medium.maxQTDE))
        DT_EXPPRIZE_MEDIUM = math.random(medium.minEXP, medium.maxEXP)
       
        DT_PRIZEID_MEDIUM = medium.prizesID
        DT_PRIZENAME_MEDIUM = medium.prizesNAME
        DT_PREMIOQTDE_MEDIUM = math.random(medium.minQTDEPremios, medium.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_MEDIUM = medium.PremioFixoID
        DT_PREMIOFIXO_NAME_MEDIUM = medium.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_MEDIUM = medium.PremioFixoQTDE
       
        DT_TASKPOINTS_MEDIUM = medium.taskPoints
   
    --HARD (200-)
        DT_CHOSENTASK_HARD = DT_TasksHard[math.random(#DT_TasksHard)]
        DT_NEEDKILL_HARD = math.ceil(math.random(hard.minQTDE, hard.maxQTDE))
        DT_EXPPRIZE_HARD = math.random(hard.minEXP, hard.maxEXP)
       
        DT_PRIZEID_HARD = hard.prizesID
        DT_PRIZENAME_HARD = hard.prizesNAME
        DT_PREMIOQTDE_HARD = math.random(hard.minQTDEPremios, hard.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_HARD = hard.PremioFixoID
        DT_PREMIOFIXO_NAME_HARD = hard.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_HARD = hard.PremioFixoQTDE
       
        DT_TASKPOINTS_HARD = hard.taskPoints
       
    --EXPERT (200+)
        DT_CHOSENTASK_EXPERT = DT_TasksExpert[math.random(#DT_TasksExpert)]
        DT_NEEDKILL_EXPERT = math.ceil(math.random(expert.minQTDE, expert.maxQTDE))
        DT_EXPPRIZE_EXPERT = math.random(expert.minEXP, expert.maxEXP)
       
        DT_PRIZEID_EXPERT = expert.prizesID
        DT_PRIZENAME_EXPERT = expert.prizesNAME
        DT_PREMIOQTDE_EXPERT = math.random(expert.minQTDEPremios, expert.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_EXPERT = expert.PremioFixoID
        DT_PREMIOFIXO_NAME_EXPERT = expert.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EXPERT = expert.PremioFixoQTDE
       
        DT_TASKPOINTS_EXPERT = expert.taskPoints

        -- FUNÇÃO PRA PEGAR OS NOMES DOS ITEM
function getAllTableText(aa, bb, cc)
local tablecheck = aa

if not tablecheck then
    return false
end

local lang = bb
local ponto = ""
if not lang then
    lang = "and"
end
if cc then
ponto = "."
end
local text = ""
for i = 1, #tablecheck do
    if i == 1 then
    text = tablecheck[i]
    elseif i == #tablecheck then
    text = text .." "..lang.." "..tablecheck[i]..""..ponto..""
    else
    text = text ..", "..tablecheck[i]
    end
end
return text
end


In /data/creaturescript/creaturescripts.xml add the tag:
Code:
<event type="kill" name="dailyTasks" script="dailyTasks.lua"/>

Register the "dailyTasks" in your login.lua


Create the dailyTasks.lua file in / data / creaturescript / scripts and put it all inside:
Code:
function onKill(player, target)
local monster = getCreatureName(target)
   
local KILL_EASY = player:getStorageValue(DT_STORAGES.EASY)
local KILL_MEDIUM = player:getStorageValue(DT_STORAGES.MEDIUM)
local KILL_HARD = player:getStorageValue(DT_STORAGES.HARD)
local KILL_EXPERT = player:getStorageValue(DT_STORAGES.EXPERT)

local isDOING = player:getStorageValue(DT_STORAGES.HAVE_STARTED)

if isDOING == 1 then
    if monster:lower() == DT_CHOSENTASK_EASY:lower() then
                player:setStorageValue(DT_STORAGES.EASY, KILL_EASY + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EASY-KILL_EASY-1 .." to kill.")
        end
    end
elseif isDOING == 2 then
    if monster:lower() == DT_CHOSENTASK_MEDIUM:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_MEDIUM + 1)
        if KILL_MEDIUM >= DT_NEEDKILL_MEDIUM then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_MEDIUM.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_MEDIUM-KILL_MEDIUM-1 .." to kill.")      
        end
    end
elseif isDOING == 3 then
    if monster:lower() == DT_CHOSENTASK_HARD:lower() then
                player:setStorageValue(DT_STORAGES.HARD, KILL_HARD + 1)
        if KILL_HARD >= DT_NEEDKILL_HARD then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_HARD.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_HARD-KILL_HARD-1 .." to kill.")      
        end
    end
elseif isDOING == 4 then
    if monster:lower() == DT_CHOSENTASK_EXPERT:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_EXPERT + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EXPERT-KILL_EXPERT-1 .." to kill.")      
        end
    end
end

return true
end

:)
how to put to get addon and mount as a reward?
 
Don't even bother trying to decipher that, that's the worst possible code, I have no idea why this dude decided to post it, its not even working in this sorry state xD
 
Last edited:
If your are using OTX3/TFS 1.3, the message in creaturescripts will debug your client (8.6). Replace with:
Lua:
function onKill(player, target)
local monster = getCreatureName(target)
   
local KILL_EASY = player:getStorageValue(DT_STORAGES.EASY)
local KILL_MEDIUM = player:getStorageValue(DT_STORAGES.MEDIUM)
local KILL_HARD = player:getStorageValue(DT_STORAGES.HARD)
local KILL_EXPERT = player:getStorageValue(DT_STORAGES.EXPERT)

local isDOING = player:getStorageValue(DT_STORAGES.HAVE_STARTED)

if isDOING == 1 then
    if monster:lower() == DT_CHOSENTASK_EASY:lower() then
                player:setStorageValue(DT_STORAGES.EASY, KILL_EASY + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You successully killed '..DT_NEEDKILL_EASY..' '..monster..'. ')
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You killed a '..monster..'. There are still '..DT_NEEDKILL_EASY-KILL_EASY-1 ..' to kill.')
        end
    end
elseif isDOING == 2 then
    if monster:lower() == DT_CHOSENTASK_MEDIUM:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_MEDIUM + 1)
        if KILL_MEDIUM >= DT_NEEDKILL_MEDIUM then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You successully killed '..DT_NEEDKILL_MEDIUM..' '..monster..'.')
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You killed a '..monster..'. There are still '..DT_NEEDKILL_MEDIUM-KILL_MEDIUM-1 ..' to kill.')      
        end
    end
elseif isDOING == 3 then
    if monster:lower() == DT_CHOSENTASK_HARD:lower() then
                player:setStorageValue(DT_STORAGES.HARD, KILL_HARD + 1)
        if KILL_HARD >= DT_NEEDKILL_HARD then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You successully killed '..DT_NEEDKILL_HARD..' '..monster..'.')
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You killed a '..monster..'. There are still '..DT_NEEDKILL_HARD-KILL_HARD-1 ..' to kill.')      
        end
    end
elseif isDOING == 4 then
    if monster:lower() == DT_CHOSENTASK_EXPERT:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_EXPERT + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You successully killed '..DT_NEEDKILL_EASY..' '..monster..'.')
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '[DAILY TASK] You killed a '..monster..'. There are still '..DT_NEEDKILL_EXPERT-KILL_EXPERT-1 ..' to kill.')      
        end
    end
end

return true
end
 
Register the "dailyTasks" in your login.lua

How to register it on TFS 1.3 ?

Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()
   
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
   


    if (player:getGroup():getId() >= 4) then
        --player:setGhostMode(true)
    end

   
    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

   
     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

   
    -- OFFlineTraining
    local offlineSkill = player:getStorageValue(45254)
    player:setStorageValue(45254, 0)
   
    if offlineSkill >= 1 then
        local lastLogout = player:getLastLogout()
        local offlineTime = os.time() - lastLogout      
        if offlineTime >= 86400  then offlineTime = 86400 end -- 24 Horas      
        local skillRate = 3 -- same config.lua
        local magicRate = 3 -- same config.lua
       
        if offlineSkill == 1 then
            --SKILL_SWORD
            player:addSkillTries(SKILL_SWORD, 10 * skillRate * offlineTime)      
        end
       
        if offlineSkill == 2 then
            --SKILL_AXE
            player:addSkillTries(SKILL_AXE, 10 * skillRate * offlineTime)  
        end
       
        if offlineSkill == 3 then
            --SKILL_CLUB
            player:addSkillTries(SKILL_CLUB, 10 * skillRate * offlineTime)      
        end
       
        if offlineSkill == 4 then
            --SKILL_DISTANCE          
            player:addSkillTries(SKILL_DISTANCE, 10 * skillRate * offlineTime)  
        end
       
        if offlineSkill == 5 then
            --SKILL_MAGLEVEL
            player:addManaSpent(math.ceil(50 * magicRate * offlineTime))  
        end
       
        --SKILL_SHIELD
        player:addSkillTries(SKILL_SHIELD, 10 * skillRate * offlineTime)
       
        offlineTime = math.ceil(offlineTime/60)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'Congratulations, you trained offline ' .. offlineTime .. ' minutes.'  )        
    end  
   
   
    player:setOutfit(player:getOutfit())  
   
   
   
    return true
end

I added:
registerCreatureEvent(cid, "dailyTasks")
But do not works ...

Im using TFS 1.3
 
Last edited:
Go to / data / npc and create the daily.xml file, open it and put it all in there:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tian" walkinterval="2000" floorchange="0" script="dailyTask.lua">
    <health now="100" max="100"/>
    <look type="128" head="0" body="112" legs="107" feet="113" addons="0"/>
</npc>

Go to / data / npc / scripts and add the file dailyTask.lua, and inside it put:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(1200, 500, -100)

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local aa, bb, cc, dd, ee, ff = 0
    local player = Player(cid)
       
        if msgcontains(msg, "help") then
            npcHandler:say("I can offer you some {daily tasks}.", cid)
        elseif msgcontains(msg, "task") or msgcontains(msg, "tasks") or msgcontains(msg, "daily") or msgcontains(msg, "tarefa") or  msgcontains(msg, "tarefas") or msgcontains(msg, "diaria") then
            if player:getStorageValue(DT_STORAGES.HAVE_STARTED) > 0 then
                return npcHandler:say("You have already started your daily task today.", cid)
            elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == -2 then
                return npcHandler:say("You have already completed your daily task today.", cid)
            end
            npcHandler:say("I have tasks of level {Easy}, {Medium}, {Hard} and {Expert}. Which one do you want to do?", cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say("What are you talking about??", cid)
        end
       
    if npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "easy") then
        if DT_PREMIOQTDE_EASY > 0 then
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EASY .."}x "..getAllTableText(DT_PRIZENAME_EASY, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        else
            npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
        end
            npcHandler.topic[cid] = 3
        elseif msgcontains(msg, "medium") then
            npcHandler:say("Your MEDIUM daily task today is: Kill {".. DT_NEEDKILL_MEDIUM .."}{ ".. DT_CHOSENTASK_MEDIUM .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_MEDIUM .."}x "..getAllTableText(DT_PRIZENAME_MEDIUM, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_MEDIUM.."}x "..DT_PREMIOFIXO_NAME_MEDIUM..";\n*{"..DT_EXPPRIZE_MEDIUM.."} Experience points;\n*{"..DT_TASKPOINTS_MEDIUM.."}x Task Point.\nDo you want to start this {MEDIUM} task?", cid)
            npcHandler.topic[cid] = 4      
        elseif msgcontains(msg, "hard") then
            npcHandler:say("Your HARD daily task today is: Kill {".. DT_NEEDKILL_HARD .."}{ ".. DT_CHOSENTASK_HARD .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_HARD .."}x "..getAllTableText(DT_PRIZENAME_HARD, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_HARD.."}x "..DT_PREMIOFIXO_NAME_HARD..";\n*{"..DT_EXPPRIZE_HARD.."} Experience points;\n*{"..DT_TASKPOINTS_HARD.."}x Task Point.\nDo you want to start this {HARD} task?", cid)
            npcHandler.topic[cid] = 5      
        elseif msgcontains(msg, "expert") then
            npcHandler:say("Your EXPERT daily task today is: Kill {".. DT_NEEDKILL_EXPERT .." }{".. DT_CHOSENTASK_EXPERT .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EXPERT .."}x "..getAllTableText(DT_PRIZENAME_EXPERT, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EXPERT.."}x "..DT_PREMIOFIXO_NAME_EXPERT..";\n*{"..DT_EXPPRIZE_EXPERT.."} Experience points;\n*{"..DT_TASKPOINTS_EXPERT.."}x Task Point.\nDo you want to start this {EXPERT} task?", cid)
            npcHandler.topic[cid] = 6      
        end
    end
    if msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 3 then  
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EASY, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 1)
        elseif npcHandler.topic[cid] == 4 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.MEDIUM, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 2)
        elseif npcHandler.topic[cid] == 5 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.HARD, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 3)
        elseif npcHandler.topic[cid] == 6 then
        npcHandler:say("Ok, don't waste time! You must kill all these monsters and return to receive your reward before {6:00 am}(GMT-3).", cid)
        player:setStorageValue(DT_STORAGES.EXPERT, 0)
        player:setStorageValue(DT_STORAGES.HAVE_STARTED, 4)
        end      
    end

    if msgcontains(msg, "report") then
        if player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 1 then
            if player:getStorageValue(DT_STORAGES.EASY) >= DT_NEEDKILL_EASY then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_EASY) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY) --fixo
                if DT_PREMIOQTDE_EASY > 0 then --rand
                    if DT_PREMIOQTDE_EASY == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EASY)
                        player:addItem(DT_PRIZEID_EASY[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EASY) do
                            aa = math.random(#DT_PRIZEID_EASY)
                            player:addItem(DT_PRIZEID_EASY[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EASY - player:getStorageValue(DT_STORAGES.EASY) .."} "..DT_CHOSENTASK_EASY.."(s).", cid)
            end          
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 2 then
            if player:getStorageValue(DT_STORAGES.MEDIUM) >= DT_NEEDKILL_MEDIUM then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_MEDIUM) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_MEDIUM, DT_PREMIOFIXO_QTDE_MEDIUM) --fixo
               
                if DT_PREMIOQTDE_MEDIUM > 0 then --rand
                    if DT_PREMIOQTDE_MEDIUM == 1 then --rand
                        aa = math.random(#DT_PRIZEID_MEDIUM)
                        player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_MEDIUM) do
                            aa = math.random(#DT_PRIZEID_MEDIUM)
                            player:addItem(DT_PRIZEID_MEDIUM[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_MEDIUM - player:getStorageValue(DT_STORAGES.MEDIUM) .."} "..DT_CHOSENTASK_MEDIUM.."(s).", cid)
            end  
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 3 then
            if player:getStorageValue(DT_STORAGES.HARD) >= DT_NEEDKILL_HARD then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_HARD) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_HARD, DT_PREMIOFIXO_QTDE_HARD) --fixo
               
                if DT_PREMIOQTDE_HARD > 0 then --rand
                    if DT_PREMIOQTDE_HARD == 1 then --rand
                        aa = math.random(#DT_PRIZEID_HARD)
                        player:addItem(DT_PRIZEID_HARD[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_HARD) do
                            aa = math.random(#DT_PRIZEID_HARD)
                            player:addItem(DT_PRIZEID_HARD[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_HARD - player:getStorageValue(DT_STORAGES.HARD) .."} "..DT_CHOSENTASK_HARD.."(s).", cid)
            end  
        elseif player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 4 then
            if player:getStorageValue(DT_STORAGES.EXPERT) >= DT_NEEDKILL_EXPERT then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
               
                player:addExperience(DT_EXPPRIZE_EXPERT) --exp
               
                player:addItem(DT_PREMIOFIXO_ID_EXPERT, DT_PREMIOFIXO_QTDE_EXPERT) --fixo
               
                if DT_PREMIOQTDE_EXPERT > 0 then --rand
                    if DT_PREMIOQTDE_EXPERT == 1 then --rand
                        aa = math.random(#DT_PRIZEID_EXPERT)
                        player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EXPERT) do
                            aa = math.random(#DT_PRIZEID_EXPERT)
                            player:addItem(DT_PRIZEID_EXPERT[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EXPERT - player:getStorageValue(DT_STORAGES.EXPERT) .."} "..DT_CHOSENTASK_EXPERT.."(s).", cid)
            end  
        else
            npcHandler:say("Uhn.. What are you talking about??", cid)
            npcHandler.topic[cid] = 0
        end
    end
end
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME| i've some {tasks} for u.")
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

In /data/lib/lib.lua, add the line:
Code:
dofile('data/lib/task/dailytask.lua')

Create the dailytask.lua file in / data / lib / task /, and put in:
Code:
-- CONFIGS

local easy = {
minQTDE = 50,
maxQTDE = 300,

minEXP = 250000,
maxEXP = 750000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 0,
maxQTDEPremios = 2,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 1,

taskPoints = 1
}

local medium = {
minQTDE = 100,
maxQTDE = 400,

minEXP = 500000,
maxEXP = 1500000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 1,
maxQTDEPremios = 3,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 2,

taskPoints = 2
}

local hard = {
minQTDE = 150,
maxQTDE = 500,

minEXP = 1000000,
maxEXP = 3000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 2,
maxQTDEPremios = 4,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 3,

taskPoints = 3
}

local expert = {
minQTDE = 200,
maxQTDE = 600,

minEXP = 2000000,
maxEXP = 6000000,

prizesID = {22607, 22604},
prizesNAME = {"Boss Key", "Hunt Key"},
minQTDEPremios = 3,
maxQTDEPremios = 5,

PremioFixoID = 25377,
PremioFixoNAME = "Gold Token",
PremioFixoQTDE = 4,

taskPoints = 4
}

DT_TasksEasy = {"Minotaur", "Minotaur Guard", "Minotaur Mage", "Minotaur Archer", "Larva", "Scarab", "Wyvern", "Rorc", "Wolf", "War Wolf", "Orc Berserker", "Orc Warrior", "Orc Shaman", "Orc Leader", "Orc", "Cyclops", "Orc Rider", "Slime", "Orc Warlord", "Water Elemental", "Quara Mantassin Scout", "Gargoyle", "Mummy", "Crypt Shambler", "Demon Skeleton", "Ghost", "Zombie", "Rotworm", "Carrion Worm", "Rotworm Queen", "Tortoise", "Thornback Tortoise", "Toad", "Crab", "Blood Crab", "Killer Caiman", "Ghoul", "Scorpion", "Banshee", "Fire Devil", "Amazon", "Valkyrie", "Witch", "Leaf Golem", "Forest Fury", "Troll", "Goblin", "Troll Champion", "Goblin Scavanger", "Goblin Assassin", "Corym Vanguard", "Corym Skirmisher", "Corym Charlatan", "Ghost Wolf", "Gloom Wolf", "Elf", "Elf Arcanist", "Elf Scout", "Firestarter", "Bat", "Swamp Troll", "Stonerefiner", "Tarantula", "Dragon Hatchling", "Nomad", "Scorpion", "Dwarf", "Dwarf Soldier", "Dwarf Guard", "Kongra", "Sibang", "Merlkin", "Gazer", "Bonelord", "Elder Bonelord", "Braindeath"}
DT_TasksMedium = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Cult Believer", "Cult Enforcer", "Cult Scholar", "Ghastly Dragon", "Lizard Chosen", "Giant Spider", "Tarantula", "Bog Raider", "Earth Elemental", "Enfeebled Silencer", "Weakened Frazzlemaw", "Noble Lion", "Ancient Scarab", "Roaring Lion", "Souleater", "Mutated Bat", "Mutated Rat", "Mutated Tiger", "Warlock", "Yielothax", "Killer Caiman", "Vampire Bridge", "Vampire Viscount", "Vampire", "Bonebeast", "Necromancer", "Quara Predator", "Quara Constrictor", "Quara Mantassin", "Quara Pincher", "Quara Hydromancer", "Quara Predator Scout", "Quara Constrictor Scout", "Quara Mantassin Scout", "Quara Pincher Scout", "Quara Hydromancer Scout", "Wyrm", "Behemoth", "Nightstalker", "Giant Spider", "Energy Elemental", "Stampor", "Bonebeast", "Orc Cult Inquisitor", "Orc Cult Minion", "Orc Cultist", "Orc Cult Priest", "Orc Cult Fanatic", "Lost Husher", "Lost Basher", "Lost Thrower", "enslaved Dwarf", "Dragon", "Dragon Lord", "Barkless Devotee", "Barkless Fanatic", "Massive Water Elemental", "Minotaur Cult Follower", "Minotaur Cult Prophet", "Minotaur Cult Zealot" }
DT_TasksHard = {"Vicious Squire", "Vile Grandmaster", "Renegade Knight", "Hero", "Necromancer", "Lich", "Werebear", "Wereboar", "Werebadger", "Werewolf", "Askarak Demon", "Shaburak Demon", "Wyrm", "Elder Wyrm", "Vampire Viscount", "Blood Priest", "Shadow Pupil", "White Shade", "Vampire", "Putrid Mummy", "Giant Spider", "Fury", "Massive Fire Elemental", "Dragonling", "Hellfire Fighter", "Diabolic Imp", "Hellhound", "Infernalist", "Behemoth", "Dawnfire Asura", "Midnight Asura", "Hellspawn", "Plaguesmith", "Medusa", "Serpent Spawn", "Hydra", "Dark Faun", "Boogy", "Twisted Pooka", "Draken Elite", "Draken Warmaster", "Draken Spellweaver", "Draken Abomination", "Lizard Legionnaire", "Lizard Dragon Priest", "Lizard High Guard", "Lizard Chosen", "Ghastly Dragon"}
DT_TasksExpert = {"Guzzlemaw", "Sight of Surrender", "Terrorsleep", "Silencer", "Dark Torturer", "Demon Outcast", "Betrayed Wraith", "Plaguesmith", "Blightwalker", "Nightmare", "Juggernault", "Hellhound", "Crazed Winter Rearguard", "Crazed Winter Vanguard", "Crazed Summer Rearguard", "Crazed Summer Vanguard", "Spiky Carnivor", "Lumbering Carnivor", "Menacing Carnivor", "Vexclaw", "Grimeleech", "Demon", "Hellflayer", "Hellfire Fighter", "Fury", "Undead Dragon", "Phantasm", "Nightmare", "Defiler", "Plaguesmith", "Spectre", "Hand of Cursed Fate", "Undead Elite Gladiator", "Skeleton Elite Warrior", "Grim Reaper", "Gravedigger", "Floating Servant", "Lava Luker Attendant", "Cobra Assassin", "Cobra Vizier", "Cobra Scout", "Dread Intruder", "Reality Reaver", "Sparkion", "Breach Brood", "Choking Fear", "Retching Horror", "Animated Feather", "Biting Book", "Brain Squid", "Burning Book", "Cursed Book", "Energetic Book", "Energuardian of Tales", "Flying Book", "Guardian of Tales", "Icecold Book", "Ink Blob", "Knowledge Elemental", "Rage Squid", "Squid Warden", "Lost Soul", "Falcon Knight", "Falcon Paladin"}

-- SCRIPT

   
    DT_STORAGES = {
        PONTOS = 367643975,
        EXPERT = 367643974,
        HARD = 367643973,
        MEDIUM = 367643972,
        EASY = 367643971,
        HAVE_STARTED = 367643970,
            }
           
    --RESETAR STORAGES
        for i = 1, 6 do
        db.query('DELETE FROM `player_storage` WHERE `player_storage`.`key` = '.. 367643969+i ..'')
        end  
       
    -- EASY (100-)
        DT_CHOSENTASK_EASY = DT_TasksEasy[math.random(#DT_TasksEasy)]
        DT_NEEDKILL_EASY = math.ceil(math.random(easy.minQTDE, easy.maxQTDE))
        DT_EXPPRIZE_EASY = math.random(easy.minEXP, easy.maxEXP)
       
        DT_PRIZEID_EASY = easy.prizesID
        DT_PRIZENAME_EASY = easy.prizesNAME
        DT_PREMIOQTDE_EASY = math.random(easy.minQTDEPremios, easy.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_EASY = easy.PremioFixoID
        DT_PREMIOFIXO_NAME_EASY = easy.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EASY = easy.PremioFixoQTDE
       
        DT_TASKPOINTS_EASY = easy.taskPoints
       
    -- MEDIUM (150-)
        DT_CHOSENTASK_MEDIUM = DT_TasksMedium[math.random(#DT_TasksMedium)]
        DT_NEEDKILL_MEDIUM = math.ceil(math.random(medium.minQTDE, medium.maxQTDE))
        DT_EXPPRIZE_MEDIUM = math.random(medium.minEXP, medium.maxEXP)
       
        DT_PRIZEID_MEDIUM = medium.prizesID
        DT_PRIZENAME_MEDIUM = medium.prizesNAME
        DT_PREMIOQTDE_MEDIUM = math.random(medium.minQTDEPremios, medium.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_MEDIUM = medium.PremioFixoID
        DT_PREMIOFIXO_NAME_MEDIUM = medium.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_MEDIUM = medium.PremioFixoQTDE
       
        DT_TASKPOINTS_MEDIUM = medium.taskPoints
   
    --HARD (200-)
        DT_CHOSENTASK_HARD = DT_TasksHard[math.random(#DT_TasksHard)]
        DT_NEEDKILL_HARD = math.ceil(math.random(hard.minQTDE, hard.maxQTDE))
        DT_EXPPRIZE_HARD = math.random(hard.minEXP, hard.maxEXP)
       
        DT_PRIZEID_HARD = hard.prizesID
        DT_PRIZENAME_HARD = hard.prizesNAME
        DT_PREMIOQTDE_HARD = math.random(hard.minQTDEPremios, hard.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_HARD = hard.PremioFixoID
        DT_PREMIOFIXO_NAME_HARD = hard.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_HARD = hard.PremioFixoQTDE
       
        DT_TASKPOINTS_HARD = hard.taskPoints
       
    --EXPERT (200+)
        DT_CHOSENTASK_EXPERT = DT_TasksExpert[math.random(#DT_TasksExpert)]
        DT_NEEDKILL_EXPERT = math.ceil(math.random(expert.minQTDE, expert.maxQTDE))
        DT_EXPPRIZE_EXPERT = math.random(expert.minEXP, expert.maxEXP)
       
        DT_PRIZEID_EXPERT = expert.prizesID
        DT_PRIZENAME_EXPERT = expert.prizesNAME
        DT_PREMIOQTDE_EXPERT = math.random(expert.minQTDEPremios, expert.maxQTDEPremios)
       
        DT_PREMIOFIXO_ID_EXPERT = expert.PremioFixoID
        DT_PREMIOFIXO_NAME_EXPERT = expert.PremioFixoNAME
        DT_PREMIOFIXO_QTDE_EXPERT = expert.PremioFixoQTDE
       
        DT_TASKPOINTS_EXPERT = expert.taskPoints

        -- FUNÇÃO PRA PEGAR OS NOMES DOS ITEM
function getAllTableText(aa, bb, cc)
local tablecheck = aa

if not tablecheck then
    return false
end

local lang = bb
local ponto = ""
if not lang then
    lang = "and"
end
if cc then
ponto = "."
end
local text = ""
for i = 1, #tablecheck do
    if i == 1 then
    text = tablecheck[i]
    elseif i == #tablecheck then
    text = text .." "..lang.." "..tablecheck[i]..""..ponto..""
    else
    text = text ..", "..tablecheck[i]
    end
end
return text
end


In /data/creaturescript/creaturescripts.xml add the tag:
Code:
<event type="kill" name="dailyTasks" script="dailyTasks.lua"/>

Register the "dailyTasks" in your login.lua


Create the dailyTasks.lua file in / data / creaturescript / scripts and put it all inside:
Code:
function onKill(player, target)
local monster = getCreatureName(target)
   
local KILL_EASY = player:getStorageValue(DT_STORAGES.EASY)
local KILL_MEDIUM = player:getStorageValue(DT_STORAGES.MEDIUM)
local KILL_HARD = player:getStorageValue(DT_STORAGES.HARD)
local KILL_EXPERT = player:getStorageValue(DT_STORAGES.EXPERT)

local isDOING = player:getStorageValue(DT_STORAGES.HAVE_STARTED)

if isDOING == 1 then
    if monster:lower() == DT_CHOSENTASK_EASY:lower() then
                player:setStorageValue(DT_STORAGES.EASY, KILL_EASY + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EASY-KILL_EASY-1 .." to kill.")
        end
    end
elseif isDOING == 2 then
    if monster:lower() == DT_CHOSENTASK_MEDIUM:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_MEDIUM + 1)
        if KILL_MEDIUM >= DT_NEEDKILL_MEDIUM then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_MEDIUM.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_MEDIUM-KILL_MEDIUM-1 .." to kill.")      
        end
    end
elseif isDOING == 3 then
    if monster:lower() == DT_CHOSENTASK_HARD:lower() then
                player:setStorageValue(DT_STORAGES.HARD, KILL_HARD + 1)
        if KILL_HARD >= DT_NEEDKILL_HARD then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_HARD.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_HARD-KILL_HARD-1 .." to kill.")      
        end
    end
elseif isDOING == 4 then
    if monster:lower() == DT_CHOSENTASK_EXPERT:lower() then
                player:setStorageValue(DT_STORAGES.MEDIUM, KILL_EXPERT + 1)
        if KILL_EASY >= DT_NEEDKILL_EASY then
                player:sendTextMessage(30, "[DAILY TASK] You successully killed "..DT_NEEDKILL_EASY.." "..monster..". Talk to Iwan about it.")
            else
                player:sendTextMessage(30, "[DAILY TASK] You killed a "..monster..". There are still "..DT_NEEDKILL_EXPERT-KILL_EXPERT-1 .." to kill.")      
        end
    end
end

return true
end

:)


All done, The npc works, it gives you the task you choose, but when you go to kill some it do not start to count...

i registered it on LOGIN.LUA using TFS 1.3, but wont works:
registerCreatureEvent(cid, "dailyTasks")


Can you help me ?
 
Selecting a new monster does not work unless you restart the server or reload the libs.
What is the problem?
 
Back
Top