# How to return all killers?

#### MorganaSacani

##### Active Member
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 },
}

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:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Reward: " .. drop[i].desc .. "!")
end
end
end

return true
end

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 },
}

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 },
}

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:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Reward: " .. drop[i].desc .. "!")
end
end
end

return true
end

`creature:getDamageMap()`
Lua:
``````for creatureId, damage in pairs(creature:getDamageMap()) do
-- do stuff
end``````

Thx

Replies
0
Views
224
Replies
6
Views
596
Replies
2
Views
187
Replies
3
Views
426
Replies
6
Views
513
Replies
2
Views
159
Replies
2
Views
267
Replies
9
Views
658
Replies
0
Views
274
Replies
6
Views
364