• 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] Task Party.

Zodia

Member
Joined
Feb 21, 2020
Messages
220
Reaction score
22
My task system seems to be set so that only the last player who attacked the monster, counts. I'm trying to get you to tell Party members to attack the monster.

Creaturescript:
LUA:
function onKill(player, target)
    local monster = config[target:getName():lower()]
    if not monster or target:getMaster() then
        return true
    local party = player:getParty()

    if party...
    for ...  party:getMembers()
    end

    local storageValue = player:getStorageValue(monster.storage)
    if storageValue >= monster.start then
        if storageValue >= monster.count then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already killed " .. monster.count .. " " .. monster.plural .. ". Report back to Tusker in Thais.")
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed [" .. storageValue .. "/" .. monster.count .. "] " .. monster.plural .. ".")
        end
            player:setStorageValue(monster.storage, storageValue + 1)
    end
    return true
end


I tried a few things using these tips:


Code:
local party = player:getParty()

if party...
    for ...  party:getMembers()



Could anyone help me with this? How would my Creaturescript code look, so that the desired result was achieved?
Of course. That count only if the Party is active, and that count only for the Party players that attack the monster.

Thanks! <3
 
agora conta +2 :(, para os 2 jogadores
Tenta esse script
Post automatically merged:

Tenta esse script para mim deu certo

LUA:
-- Função para determinar se um jogador está em uma party
local function isInParty(jogador)
    return jogador:getParty()
end

-- Função para obter os jogadores que mataram o monstro, considerando party ou solo
local function getKillers(criatura, jogador)
    local assassinos = {}
    local tempoAtual = os.mtime()
    local ticksEmLuta = configManager.getNumber(configKeys.PZ_LOCKED)
    
    for uid, cb in pairs(criatura:getDamageMap()) do
        local atacante = Player(uid)
        if atacante and atacante ~= criatura and tempoAtual - cb.ticks <= ticksEmLuta then
            if isInParty(atacante) and isInParty(jogador) then
                if atacante:getParty() == jogador:getParty() then
                    table.insert(assassinos, atacante)
                end
            elseif not isInParty(atacante) and not isInParty(jogador) then
                table.insert(assassinos, atacante)
            end
        end
    end
    
    return assassinos
end

-- Função principal para lidar com o evento de matar
function onKill(jogador, alvo)
    local monstro = config[alvo:getName():lower()]
    if not monstro or alvo:getMaster() then
        return true
    end
    
    local assassinos = getKillers(alvo, jogador)
    
    for _, membro in ipairs(assassinos) do
        local valorArmazenado = membro:getStorageValue(monstro.storage)
        if valorArmazenado >= monstro.start then
            if valorArmazenado >= monstro.count then
                membro:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already killed " .. monstro.count .. " " .. monstro.plural .. ". Relate a Tusker.")
            else
                membro:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed [" .. valorArmazenado .. "/" .. monstro.count .. "] " .. monstro.plural .. ".")
            end
            membro:setStorageValue(monstro.storage, valorArmazenado + 1)
        end
    end
    
    return true
end
 
Last edited:
now counts +2 :(, to the 2 players
tenta esse scipt para mim deu certo

LUA:
-- Função para determinar se um jogador está em uma party
local function isInParty(jogador)
    return jogador:getParty()
end

-- Função para obter os jogadores que mataram o monstro, considerando party ou solo
local function getKillers(criatura, jogador)
    local assassinos = {}
    local tempoAtual = os.mtime()
    local ticksEmLuta = configManager.getNumber(configKeys.PZ_LOCKED)
    
    for uid, cb in pairs(criatura:getDamageMap()) do
        local atacante = Player(uid)
        if atacante and atacante ~= criatura and tempoAtual - cb.ticks <= ticksEmLuta then
            if isInParty(atacante) and isInParty(jogador) then
                if atacante:getParty() == jogador:getParty() then
                    table.insert(assassinos, atacante)
                end
            elseif not isInParty(atacante) and not isInParty(jogador) then
                table.insert(assassinos, atacante)
            end
        end
    end
    
    return assassinos
end

-- Função principal para lidar com o evento de matar
function onKill(jogador, alvo)
    local monstro = config[alvo:getName():lower()]
    if not monstro or alvo:getMaster() then
        return true
    end
    
    local assassinos = getKillers(alvo, jogador)
    
    for _, membro in ipairs(assassinos) do
        local valorArmazenado = membro:getStorageValue(monstro.storage)
        if valorArmazenado >= monstro.start then
            if valorArmazenado >= monstro.count then
                membro:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already killed " .. monstro.count .. " " .. monstro.plural .. ". Relate a Tusker.")
            else
                membro:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed [" .. valorArmazenado .. "/" .. monstro.count .. "] " .. monstro.plural .. ".")
            end
            membro:setStorageValue(monstro.storage, valorArmazenado + 1)
        end
    end
    
    return true
end
 
Back
Top