Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Luciano committed Jan 13, 2024
1 parent 370349c commit 1fbfd89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
30 changes: 16 additions & 14 deletions data-canary/scripts/creaturescripts/player_death.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
Webhook.sendMessage(":skull_crossbones: " .. player:getMarkdownLink() .. " has died. Killed at level _" .. player:getLevel() .. "_ by **" .. killerName .. "**.", announcementChannels["player-kills"])
-- End Webhook Player Death

local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)
if maxDeathRecords then
local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)

local deathRecords = 0
local tmpResultId = resultId
while tmpResultId do
tmpResultId = Result.next(resultId)
deathRecords = deathRecords + 1
end
local deathRecords = 0
local tmpResultId = resultId
while tmpResultId do
tmpResultId = Result.next(resultId)
deathRecords = deathRecords + 1
end

if resultId then
Result.free(resultId)
end
if resultId then
Result.free(resultId)
end

local limit = deathRecords - maxDeathRecords
if limit > 0 then
db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
local limit = deathRecords - maxDeathRecords
if limit > 0 then
db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
end
end

if byPlayer == 1 then
Expand All @@ -95,7 +97,7 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
killerGuild = killerGuild and killerGuild:getId() or 0
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(player:getId(), killer:getId()) then
local warId = false
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND \z
local resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND \z
((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR \z
(`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
if resultId then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local deathListEnabled = true
local maxDeathRecords = 10
local maxDeathRecords = false

local playerDeath = CreatureEvent("PlayerDeath")

Expand Down Expand Up @@ -73,22 +73,24 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
Webhook.sendMessage(":skull_crossbones: " .. player:getMarkdownLink() .. " has died. Killed at level _" .. player:getLevel() .. "_ by **" .. killerName .. "**.", announcementChannels["player-kills"])
-- End Webhook Player Death

local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)
if maxDeathRecords then
local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)

local deathRecords = 0
local tmpResultId = resultId
while tmpResultId do
tmpResultId = Result.next(resultId)
deathRecords = deathRecords + 1
end
local deathRecords = 0
local tmpResultId = resultId
while tmpResultId do
tmpResultId = Result.next(resultId)
deathRecords = deathRecords + 1
end

if resultId then
Result.free(resultId)
end
if resultId then
Result.free(resultId)
end

local limit = deathRecords - maxDeathRecords
if limit > 0 then
db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
local limit = deathRecords - maxDeathRecords
if limit > 0 then
db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
end
end

if byPlayer == 1 then
Expand All @@ -99,7 +101,7 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
killerGuild = killerGuild and killerGuild:getId() or 0
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(player:getId(), killer:getId()) then
local warId = false
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND \z
local resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND \z
((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR \z
(`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
if resultId then
Expand Down

0 comments on commit 1fbfd89

Please sign in to comment.