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

How to return all killers?

MorganaSacani

Active Member
Joined
Sep 20, 2022
Messages
87
Solutions
1
Reaction score
32
I'm making a script, but the algoritm is returning only one killer. I want to return all killers:
Lua:
local drop = {
    [1] = { itemId = 3423, desc = "blessed shield", chance = 20 },
    [2] = { itemId = 3278, desc = "magic longsword", chance = 20 },
    [3] = { itemId = 3390, desc = "horned helmet", chance = 20 },
}

local madKnight = CreatureEvent("MadKnight")
function madKnight.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    if killer:isPlayer() then
        for i = 1, #drop, 1 do
            if math.random(1, 100000) <= drop[i].chance then
                killer:addItem(drop[i].itemId, 1)
                killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Reward: " .. drop[i].desc .. "!")
            end
        end
    end

    return true
end

madKnight:register()
 
Solution
I'm making a script, but the algoritm is returning only one killer. I want to return all killers:
Lua:
local drop = {
    [1] = { itemId = 3423, desc = "blessed shield", chance = 20 },
    [2] = { itemId = 3278, desc = "magic longsword", chance = 20 },
    [3] = { itemId = 3390, desc = "horned helmet", chance = 20 },
}

local madKnight = CreatureEvent("MadKnight")
function madKnight.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    if killer:isPlayer() then
        for i = 1, #drop, 1 do
            if math.random(1, 100000) <= drop[i].chance then...
I'm making a script, but the algoritm is returning only one killer. I want to return all killers:
Lua:
local drop = {
    [1] = { itemId = 3423, desc = "blessed shield", chance = 20 },
    [2] = { itemId = 3278, desc = "magic longsword", chance = 20 },
    [3] = { itemId = 3390, desc = "horned helmet", chance = 20 },
}

local madKnight = CreatureEvent("MadKnight")
function madKnight.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster or targetMonster:getMaster() then
        return true
    end

    if killer:isPlayer() then
        for i = 1, #drop, 1 do
            if math.random(1, 100000) <= drop[i].chance then
                killer:addItem(drop[i].itemId, 1)
                killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Reward: " .. drop[i].desc .. "!")
            end
        end
    end

    return true
end

madKnight:register()
creature:getDamageMap()
Lua:
for creatureId, damage in pairs(creature:getDamageMap()) do
    -- do stuff
end
 
Solution
Back
Top