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

task party share tfs 1.2

shakal1994

Member
Joined
Nov 20, 2020
Messages
79
Reaction score
17
I wanted a party system where everyone who attacked the monsters would get a score.

My current script
LUA:
function onKill(player, target)

    if target:isPlayer() or target:getMaster() then
        return true
    end

    local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
    
    for i = 1, #startedTasks do
        taskId = startedTasks
        if isInArray(tasks[taskId].creatures, targetName) then
            local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
            if killAmount < tasks[taskId].killsRequired then
                player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You kill: ' .. killAmount + 1 .. "/" .. tasks[taskId].killsRequired .. " " ..tasks[taskId].raceName)
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You complete task of ' ..tasks[taskId].raceName)
            end
        end
    end

    return true
end
 
I wanted a party system where everyone who attacked the monsters would get a score.

My current script
LUA:
function onKill(player, target)

    if target:isPlayer() or target:getMaster() then
        return true
    end

    local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
   
    for i = 1, #startedTasks do
        taskId = startedTasks
        if isInArray(tasks[taskId].creatures, targetName) then
            local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
            if killAmount < tasks[taskId].killsRequired then
                player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You kill: ' .. killAmount + 1 .. "/" .. tasks[taskId].killsRequired .. " " ..tasks[taskId].raceName)
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You complete task of ' ..tasks[taskId].raceName)
            end
        end
    end

    return true
end
with the code you provide i did this fixes, check if it works for you its based on TFS 1.5
LUA:
function onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end

    local targetName = target:getName():lower()
    local party = player:getParty()
    local playersToReward = {}

    if party then
        -- Get all party members
        for _, member in ipairs(party:getMembers()) do
            table.insert(playersToReward, member)
        end
        table.insert(playersToReward, party:getLeader())
    else
        table.insert(playersToReward, player)
    end

    for _, member in ipairs(playersToReward) do
        local startedTasks = member:getStartedTasks()
        
        for i = 1, #startedTasks do
            local taskId = startedTasks[i]
            if isInArray(tasks[taskId].creatures, targetName) then
                local killAmount = member:getStorageValue(KILLSSTORAGE_BASE + taskId)
                if killAmount < tasks[taskId].killsRequired then
                    member:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
                    member:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You kill: ' .. killAmount + 1 .. "/" .. tasks[taskId].killsRequired .. " " .. tasks[taskId].raceName)
                else
                    member:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You complete task of ' .. tasks[taskId].raceName)
                end
            end
        end
    end

    return true
end
 

Similar threads

Back
Top