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()