E
Evil Puncker
Guest
hello everyone, I'm trying to do a script to give achievement to the player that did the most damage to the creature, and there is a table with creatures, it looks like this:
it is just a draft, I need help with the getDamageMap() to get the most damage one, and help with how to get the values from the table
any help is appreciated
Lua:
local config = {
-- [names] {amount, achievement}
["Shaburak Demon", "Shaburak Prince"] = {amount = 400, achievement = "Shaburak Nemesis"},
["Askarak Prince", "Askarak Demon"] = {amount = 400, achievement = "Askarak Nemesis"},
["Slayer of Anmothra"] = {amount = 1, achievement = "Slayer of Anmothra"}
}
function onKill(creature, target)
if not target:isMonster() or target:getMaster() then
return true
end
local targetName = target:getName():lower()
if targetName ~= creatureName then
return true
end
for attackerId, damage in pairs(target:getDamageMap()) do
local tmpPlayer = Player(attackerId)
if tmpPlayer then
end
if config.amount > 1 then
player:addAchievementProgress(config.achievement, config.amount)
else
player:addAchievement(config.achievement)
end
end
return true
end
it is just a draft, I need help with the getDamageMap() to get the most damage one, and help with how to get the values from the table
any help is appreciated