darkmu
Well-Known Member
FOR TFS 1.X
What is happening and that sometimes when the boss is killed by a lot of people, he is sending several boss points, where did I go wrong?
What is happening and that sometimes when the boss is killed by a lot of people, he is sending several boss points, where did I go wrong?
Lua:
-- ALTER TABLE `players` ADD `boss_points` INT(6) DEFAULT 0
function addPontosBoss(playerID, pontos)
local resultId = db.storeQuery(string.format('SELECT `boss_points` FROM `players` WHERE `id` = %i;', playerID))
if resultId then
local pontosResult = result.getDataInt(resultId, 'boss_points'),
result.free(resultId)
db.query(string.format('UPDATE `players` SET `boss_points` = %i + %i WHERE `id` = %i;', 1, pontosResult, playerID))
end
return true
end
local config = {
[1] = { monsters = {"lloyd", "lady tenebris", "faceless bane", "ratmiral blackwhiskers", "drume", "sir baeloc", "lord azaram", "count vlarkorth", "earl osam", "duke krule", "soul of dragonking zyrtarch", "malofur mangrinder", "maxxenius", "melting frozen horror", "urmahlullu the weakened" , "the fear feaster", "the dread maiden", "brain head", "the nightmare beast", "plagueroot"}, bossPoints = 3},
[2] = { monsters = {"the pale worm", "king zelos", "the time guardian", "alptramun", "ancient spawn of morgathla", "razzagorn", "mazzinor", "lokathmor", "gorzindel", "ghulosh", "ragiaz", "world devourer", "the last lore keeper"}, bossPoints = 6},
[3] = { monsters = {"morgaroth", "orshabaal", "ghazbaran"}, bossPoints = 15},
[4] = { monsters = {"massacre", "dracola", "the imperor", "the plasmother", "mr. punish"} , bossPoints = 8},
[5] = { monsters = {"gaz'haragoth", "ferumbras mortal shell"}, bossPoints = 30}
}
function onKill(player, creature, lastHit)
if not player:isPlayer() or not creature:isMonster() or creature:isPlayer() then
return true
end
for i = 1, #config do
local monster = config[i]
if isInArray(monster.monsters, creature:getName():lower()) then
for cid, damage in pairs(creature:getDamageMap()) do
local participant = Player(cid)
if participant and participant:isPlayer() then
local randomBossPoints = math.random(1, monster.bossPoints)
addPontosBoss(participant:getGuid(), math.random(1, randomBossPoints))
participant:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
participant:say(string.format('%d Boss Points', randomBossPoints), TALKTYPE_MONSTER_SAY)
end
end
end
end
return true
end