@@ -46,9 +46,23 @@ local function getMostDamageInfo(mostDamageKiller)
4646 return mostDamageKillerName , byPlayerMostDamage
4747end
4848
49- local function saveDeathRecord (playerGuid , player , killerName , byPlayer , mostDamageName , byPlayerMostDamage , unjustified , mostDamageUnjustified )
49+ local function serializeParticipants (participants )
50+ if not participants or # participants == 0 then
51+ return " "
52+ end
53+
54+ local result = {}
55+ for _ , participant in ipairs (participants ) do
56+ local entry = string.format (" Name: %s\n Type: %s" , participant .name , participant .type )
57+ result [# result + 1 ] = entry
58+ end
59+ return table.concat (result , " \n\n " )
60+ end
61+
62+ local function saveDeathRecord (playerGuid , player , killerName , byPlayer , mostDamageName , byPlayerMostDamage , unjustified , mostDamageUnjustified , participants )
63+ local participantsString = serializeParticipants (participants )
5064 local query = string.format (
51- " INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) " .. " VALUES (%d, %d, %d, %s, %d, %s, %d, %d, %d)" ,
65+ " INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`, `participants` ) " .. " VALUES (%d, %d, %d, %s, %d, %s, %d, %d, %d, %s )" ,
5266 playerGuid ,
5367 os.time (),
5468 player :getLevel (),
@@ -57,7 +71,8 @@ local function saveDeathRecord(playerGuid, player, killerName, byPlayer, mostDam
5771 db .escapeString (mostDamageName ),
5872 byPlayerMostDamage ,
5973 unjustified and 1 or 0 ,
60- mostDamageUnjustified and 1 or 0
74+ mostDamageUnjustified and 1 or 0 ,
75+ db .escapeString (participantsString )
6176 )
6277 db .query (query )
6378end
@@ -168,6 +183,14 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
168183 return
169184 end
170185
186+ local killers = player :getKillers (false )
187+ local participants = {}
188+ for _ , entry in ipairs (killers ) do
189+ local name = entry :isMonster () and entry :getType ():getNameDescription () or entry :getName ()
190+ local type = entry :isPlayer () and " player" or " monster"
191+ participants [# participants + 1 ] = { name = name , type = type }
192+ end
193+
171194 local killerName , byPlayer = getKillerInfo (killer )
172195 local mostDamageName , byPlayerMostDamage = getMostDamageInfo (mostDamageKiller )
173196
@@ -178,7 +201,7 @@ function playerDeath.onDeath(player, corpse, killer, mostDamageKiller, unjustifi
178201 end
179202
180203 local playerGuid = player :getGuid ()
181- saveDeathRecord (playerGuid , player , killerName , byPlayer , mostDamageName , byPlayerMostDamage , unjustified , mostDamageUnjustified )
204+ saveDeathRecord (playerGuid , player , killerName , byPlayer , mostDamageName , byPlayerMostDamage , unjustified , mostDamageUnjustified , participants )
182205
183206 Webhook .sendMessage (" :skull_crossbones: " .. player :getMarkdownLink () .. " has died. Killed at level _" .. player :getLevel () .. " _ by **" .. killerName .. " **." , announcementChannels [" player-kills" ])
184207 handleGuildWar (player , killer , mostDamageKiller , killerName , mostDamageName )
0 commit comments