From 01be7d8dd13a839e41d71026516d10c3dd33ffb7 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Thu, 20 Apr 2023 11:35:38 +0200 Subject: [PATCH] add name of user to player route --- src/client/client.ts | 4 ++++ src/process/onKill.ts | 2 ++ src/process/process.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/client/client.ts b/src/client/client.ts index e4819cd..c11b4d1 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -37,6 +37,8 @@ router.get( kills: number max_distance: number total_distance: number + username?: string + host?: number } } = {} let index: 'cause_of_death' | 'attacker_id' | 'map' | 'servername' @@ -66,6 +68,8 @@ router.get( max_distance: 0, total_distance: 0 } + if (index === 'attacker_id') data[e[index]].username = e.attacker_name + if (index === 'servername') data[e[index]].host = e.host data[e[index]].deaths += Number(e.deaths) data[e[index]].kills += Number(e.kills) data[e[index]].total_distance += Number(e.total_distance) diff --git a/src/process/onKill.ts b/src/process/onKill.ts index 5ef0387..0accb23 100644 --- a/src/process/onKill.ts +++ b/src/process/onKill.ts @@ -39,6 +39,7 @@ export default async function listenKills() { deaths: 0, max_distance: 0, total_distance: 0, + attacker_name: payload.attacker_name, attacker_id: payload.attacker_id, cause_of_death: payload.cause_of_death, game_mode: payload.game_mode, @@ -55,6 +56,7 @@ export default async function listenKills() { deaths: 0, max_distance: 0, total_distance: 0, + attacker_name: payload.victim_name, attacker_id: payload.victim_id, cause_of_death: payload.victim_current_weapon, game_mode: payload.game_mode, diff --git a/src/process/process.ts b/src/process/process.ts index ea5bbd8..132926e 100644 --- a/src/process/process.ts +++ b/src/process/process.ts @@ -39,6 +39,7 @@ async function processGlobalStats() { 'total_distance' ), 'attacker_id', + sql`last(attacker_name)`.as('attacker_name'), 'cause_of_death', 'map', 'game_mode', @@ -62,6 +63,7 @@ async function processGlobalStats() { count('id').as('deaths'), 'victim_id', 'victim_current_weapon', + sql`last(attacker_name)`.as('attacker_name'), 'map', 'game_mode', 'servername',