• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua TFS 1.2 Is there any Kill Task system out here in otland?

SixNine

Active Member
Joined
Dec 12, 2018
Messages
452
Reaction score
41
I was looking for task system in this forum for entire day and couldnt find anything decent that would have level requirement and could be repeated multiple times all of those tasks didnt had those two most important parts

I saw Itutorial advanced task npc which had a lot of potential but still had those two issues i mentioned

Already looked in threads like
and a lot more...
 
I said in my thread that making an NPC that can do everything someone might want is just too much code. So anyone that needed a system like that could PM me and I would help them with it.
 
I said in my thread that making an NPC that can do everything someone might want is just too much code. So anyone that needed a system like that could PM me and I would help them with it.
I think i messaged you like few months ago about same question asking if you can adjust that code and if im not wrong you mentioned that you trying to figure out a smart way how to do it that everyone would know how to use it, but i guess it just died out :D
 
Bumping this thread because got a task system but it has three issues that would be great to solve. The issues im talking about

  1. Doesnt give rewards (no errors)
  2. Once you take task it says You must kill: (51) rats('s). when it should say You must kill: (50) rats('s). (so basically it adds one more for some reason)
  3. Issue with creature count it says
22:57 (2) Rats LvL 1 left.
22:57 (1) Rats LvL 1 left.
22:57 (0) Rats LvL 1 left.
22:57 You have finished the Undeads task.

when it should be

22:57 (2) Rrats LvL 1 left.
22:57 (1) Rats LvL 1 left.
22:57 You have finished the Undeads task.

Code
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 tasks = {
    [1] = {id = 1, levelReq = 1, msg = "{Rats} have been terrorizing the undergrounds of west. I need you to {kill 50 of them}.",
        name = {"Rats", "rats", "1"},
        monsters = {
            [1] = {name = "rats", amount = 50, storage = 6601}
        },
        exp = 10000,
        itemRewards = {{2160, 25}, {2152, 1}}
        },
    [2] = {id = 2, levelReq = 5, msg = "Some Message.",
        name = {"orcs", "Orcs", "2"},
        monsters = {
            [1] = {name = "Orc", amount = 50, storage = 6602}
        },
        exp = 50000,
        itemRewards = {{2152, 5}}
        }
}

local taskStorage = 6500

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if not player then return true end
    
    if msg and msg == "tasks" or msg == "mission" then
        local text = "Tasks: "
        for i = 1, #tasks do
            if i == #tasks then
                text = text..""..tasks[i].name[1].."."
            else
                text = text..""..tasks[i].name[1]..", "
            end
        end
        
        selfSay(text, cid)
        return true
        
    elseif msg and msg ~= "cancel" then
        local TASK = nil
        
        for i = 1, #tasks do
            if isInArray(tasks[i].name, msg) then
                TASK = tasks[i]
                break
            end
        end
        
        if not TASK then return true end
        
        local playerTask = tasks[player:getStorageValue(taskStorage)]
        
        if player:getStorageValue(taskStorage) == nil or player:getStorageValue(taskStorage) == -1 then
            player:setStorageValue(taskStorage, TASK.id)
            selfSay(TASK.msg, cid)
            return true
        end
            
        if player:getStorageValue(taskStorage) ~= playerTask.id then
            selfSay("You must complete the "..playerTask.name[1].." task first. You can also {clear task}.", cid)
            return true
    
        else
            local isComplete = true
        
            for i = 1, #TASK.monsters do
                if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                    isComplete = false
                    break
                end
            end
        
            if not isComplete then
              local text = "First you have to finish your current task: "
                    for i = 1, #playerTask.monsters do
                        if i == #playerTask.monsters then
                            text = text.."("..playerTask.monsters[i].amount - player:getStorageValue(playerTask.monsters[i].storage)..") "..playerTask.monsters[i].name.."('s)."
                        else
                            text = text.."("..playerTask.monsters[i].amount - player:getStorageValue(playerTask.monsters[i].storage)..") "..playerTask.monsters[i].name.."('s), "
                        end
                    end
                        
                selfSay(text, cid)
                return true
                
            else
            
                player:setStorageValue(taskStorage, -1)
                for i = 1, #TASK.monsters do
                    player:setStorageValue(TASK.monsters[i].storage, -1)
                end
                if TASK.exp then
                    player:addExperience(TASK.exp)
                end
                
                if TASK.itemRewards then
                    player:addItem(TASK.itemRewards[1], TASK.itemRewards[2])
                end
                
                selfSay("You have completed the "..TASK.name[1].." task!", cid)
                return true
            end
        end
        
    elseif msg == "cancel" then
        local TASK = tasks[player:getStorageValue(taskStorage)]
        
        if not TASK then
            selfSay("You do not have a task.", cid)
        else
            player:setStorageValue(taskStorage, -1)
            for i = 1, #TASK.monsters do
                player:setStorageValue(TASK.monsters[i].storage, -1)
            end
            selfSay("You are no longer doing the "..TASK.name[1].." task.", cid)
            return true
        end
    end
    return true
end

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

creaturescript
Lua:
local tasks = {
    [1] = {taskName = "Undeads",
        monsters = {
            [1] = {name = {"Rat LvL 1", "Rat LvL 2", "Rat  LvL 3"}, amount = 50, storage = 6601}
        }
    }
}

local taskStorage = 6500

-- Don't touch --
for i = 1, #tasks do
    for x = 1, #tasks[i].monsters do
        for z = 1, #tasks[i].monsters[x].name do
            tasks[i].monsters[x].name[z] = tasks[i].monsters[x].name[z]:lower()
        end
    end
end
----------------

function onKill(creature, target)
    if not creature:isPlayer() then return true end
    
    if not target:isMonster() or target:getMaster() then return true end
    
    local player = Player(creature)
    
    if player:getStorageValue(taskStorage) ~= nil and player:getStorageValue(taskStorage) ~= -1 then
        local TASK = tasks[player:getStorageValue(taskStorage)]
            
        if not TASK then return true end
        
        local MONSTERTABLE = nil
        
        for i = 1, #TASK.monsters do
            if isInArray(TASK.monsters[i].name, target:getName():lower()) then
                MONSTERTABLE = TASK.monsters[i]
                break
            end
        end
        
        if not MONSTERTABLE then return true end

            if player:getStorageValue(MONSTERTABLE.storage) < MONSTERTABLE.amount then
                player:setStorageValue(MONSTERTABLE.storage, player:getStorageValue(MONSTERTABLE.storage) + 1)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "("..MONSTERTABLE.amount - player:getStorageValue(MONSTERTABLE.storage)..") "..target:getName().." left.")
            else
                local isComplete = true
                for i = 1, #TASK.monsters do
                    if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                        isComplete = false
                        break
                    end
                end
                
                if isComplete then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have finished the "..TASK.taskName.." task.")
                else
                    local text = "[Task]: "
                    
                    for i = 1, #TASK.monsters do
                        if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                            if i == #TASK.monsters then
                                text = text.."("..TASK.monsters[i].amount - player:getStorageValue(TASK.monsters[i].storage)..") "..TASK.monsters[i].name[1].."."
                            else
                                text = text.."("..TASK.monsters[i].amount - player:getStorageValue(TASK.monsters[i].storage)..") "..TASK.monsters[i].name[1]..", "
                            end
                        end
                    end
                
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, text)
                end
            end
    end
return true
end
 
Bumping this thread because got a task system but it has three issues that would be great to solve. The issues im talking about

  1. Doesnt give rewards (no errors)
  2. Once you take task it says You must kill: (51) rats('s). when it should say You must kill: (50) rats('s). (so basically it adds one more for some reason)
  3. Issue with creature count it says
22:57 (2) Rats LvL 1 left.
22:57 (1) Rats LvL 1 left.
22:57 (0) Rats LvL 1 left.
22:57 You have finished the Undeads task.

when it should be

22:57 (2) Rrats LvL 1 left.
22:57 (1) Rats LvL 1 left.
22:57 You have finished the Undeads task.

Code
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 tasks = {
    [1] = {id = 1, levelReq = 1, msg = "{Rats} have been terrorizing the undergrounds of west. I need you to {kill 50 of them}.",
        name = {"Rats", "rats", "1"},
        monsters = {
            [1] = {name = "rats", amount = 50, storage = 6601}
        },
        exp = 10000,
        itemRewards = {{2160, 25}, {2152, 1}}
        },
    [2] = {id = 2, levelReq = 5, msg = "Some Message.",
        name = {"orcs", "Orcs", "2"},
        monsters = {
            [1] = {name = "Orc", amount = 50, storage = 6602}
        },
        exp = 50000,
        itemRewards = {{2152, 5}}
        }
}

local taskStorage = 6500

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if not player then return true end
   
    if msg and msg == "tasks" or msg == "mission" then
        local text = "Tasks: "
        for i = 1, #tasks do
            if i == #tasks then
                text = text..""..tasks[i].name[1].."."
            else
                text = text..""..tasks[i].name[1]..", "
            end
        end
       
        selfSay(text, cid)
        return true
       
    elseif msg and msg ~= "cancel" then
        local TASK = nil
       
        for i = 1, #tasks do
            if isInArray(tasks[i].name, msg) then
                TASK = tasks[i]
                break
            end
        end
       
        if not TASK then return true end
       
        local playerTask = tasks[player:getStorageValue(taskStorage)]
       
        if player:getStorageValue(taskStorage) == nil or player:getStorageValue(taskStorage) == -1 then
            player:setStorageValue(taskStorage, TASK.id)
            selfSay(TASK.msg, cid)
            return true
        end
           
        if player:getStorageValue(taskStorage) ~= playerTask.id then
            selfSay("You must complete the "..playerTask.name[1].." task first. You can also {clear task}.", cid)
            return true
   
        else
            local isComplete = true
       
            for i = 1, #TASK.monsters do
                if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                    isComplete = false
                    break
                end
            end
       
            if not isComplete then
              local text = "First you have to finish your current task: "
                    for i = 1, #playerTask.monsters do
                        if i == #playerTask.monsters then
                            text = text.."("..playerTask.monsters[i].amount - player:getStorageValue(playerTask.monsters[i].storage)..") "..playerTask.monsters[i].name.."('s)."
                        else
                            text = text.."("..playerTask.monsters[i].amount - player:getStorageValue(playerTask.monsters[i].storage)..") "..playerTask.monsters[i].name.."('s), "
                        end
                    end
                       
                selfSay(text, cid)
                return true
               
            else
           
                player:setStorageValue(taskStorage, -1)
                for i = 1, #TASK.monsters do
                    player:setStorageValue(TASK.monsters[i].storage, -1)
                end
                if TASK.exp then
                    player:addExperience(TASK.exp)
                end
               
                if TASK.itemRewards then
                    player:addItem(TASK.itemRewards[1], TASK.itemRewards[2])
                end
               
                selfSay("You have completed the "..TASK.name[1].." task!", cid)
                return true
            end
        end
       
    elseif msg == "cancel" then
        local TASK = tasks[player:getStorageValue(taskStorage)]
       
        if not TASK then
            selfSay("You do not have a task.", cid)
        else
            player:setStorageValue(taskStorage, -1)
            for i = 1, #TASK.monsters do
                player:setStorageValue(TASK.monsters[i].storage, -1)
            end
            selfSay("You are no longer doing the "..TASK.name[1].." task.", cid)
            return true
        end
    end
    return true
end

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

creaturescript
Lua:
local tasks = {
    [1] = {taskName = "Undeads",
        monsters = {
            [1] = {name = {"Rat LvL 1", "Rat LvL 2", "Rat  LvL 3"}, amount = 50, storage = 6601}
        }
    }
}

local taskStorage = 6500

-- Don't touch --
for i = 1, #tasks do
    for x = 1, #tasks[i].monsters do
        for z = 1, #tasks[i].monsters[x].name do
            tasks[i].monsters[x].name[z] = tasks[i].monsters[x].name[z]:lower()
        end
    end
end
----------------

function onKill(creature, target)
    if not creature:isPlayer() then return true end
   
    if not target:isMonster() or target:getMaster() then return true end
   
    local player = Player(creature)
   
    if player:getStorageValue(taskStorage) ~= nil and player:getStorageValue(taskStorage) ~= -1 then
        local TASK = tasks[player:getStorageValue(taskStorage)]
           
        if not TASK then return true end
       
        local MONSTERTABLE = nil
       
        for i = 1, #TASK.monsters do
            if isInArray(TASK.monsters[i].name, target:getName():lower()) then
                MONSTERTABLE = TASK.monsters[i]
                break
            end
        end
       
        if not MONSTERTABLE then return true end

            if player:getStorageValue(MONSTERTABLE.storage) < MONSTERTABLE.amount then
                player:setStorageValue(MONSTERTABLE.storage, player:getStorageValue(MONSTERTABLE.storage) + 1)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "("..MONSTERTABLE.amount - player:getStorageValue(MONSTERTABLE.storage)..") "..target:getName().." left.")
            else
                local isComplete = true
                for i = 1, #TASK.monsters do
                    if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                        isComplete = false
                        break
                    end
                end
               
                if isComplete then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have finished the "..TASK.taskName.." task.")
                else
                    local text = "[Task]: "
                   
                    for i = 1, #TASK.monsters do
                        if player:getStorageValue(TASK.monsters[i].storage) ~= TASK.monsters[i].amount then
                            if i == #TASK.monsters then
                                text = text.."("..TASK.monsters[i].amount - player:getStorageValue(TASK.monsters[i].storage)..") "..TASK.monsters[i].name[1].."."
                            else
                                text = text.."("..TASK.monsters[i].amount - player:getStorageValue(TASK.monsters[i].storage)..") "..TASK.monsters[i].name[1]..", "
                            end
                        end
                    end
               
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, text)
                end
            end
    end
return true
end
bump
 
Back
Top