Skip to content

Commit 42f99c3

Browse files
committed
Fraggers in characters page for TFS 1.x and canary
1 parent 4f49653 commit 42f99c3

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

system/pages/characters.php

+31-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* @copyright 2019 MyAAC
99
* @link https://my-aac.org
1010
*/
11+
12+
use MyAAC\Models\PlayerDeath;
13+
1114
defined('MYAAC') or die('Direct access not allowed!');
1215
$title = 'Characters';
1316

@@ -322,17 +325,35 @@ function retrieve_former_name($name)
322325

323326
$frags = array();
324327
$frag_add_content = '';
325-
if($config['characters']['frags'] && $db->hasTable('killers')) {
326-
//frags list by Xampy
327-
$i = 0;
328+
if ($config['characters']['frags']) {
328329
$frags_limit = 10; // frags limit to show? // default: 10
329-
$player_frags = $db->query('SELECT `player_deaths`.*, `players`.`name`, `killers`.`unjustified` FROM `player_deaths` LEFT JOIN `killers` ON `killers`.`death_id` = `player_deaths`.`id` LEFT JOIN `player_killers` ON `player_killers`.`kill_id` = `killers`.`id` LEFT JOIN `players` ON `players`.`id` = `player_deaths`.`player_id` WHERE `player_killers`.`player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,'.$frags_limit.';')->fetchAll();
330-
if(count($player_frags)) {
331-
$row_count = 0;
332-
foreach($player_frags as $frag)
333-
{
334-
$description = 'Fragged <a href="' . getPlayerLink($frag['name'], false) . '">' . $frag['name'] . '</a> at level ' . $frag['level'];
335-
$frags[] = array('time' => $frag['date'], 'description' => $description, 'unjustified' => $frag['unjustified'] != 0);
330+
331+
if ($db->hasTable('killers')) {
332+
//frags list by Xampy
333+
$i = 0;
334+
$player_frags = $db->query('SELECT `player_deaths`.*, `players`.`name`, `killers`.`unjustified` FROM `player_deaths` LEFT JOIN `killers` ON `killers`.`death_id` = `player_deaths`.`id` LEFT JOIN `player_killers` ON `player_killers`.`kill_id` = `killers`.`id` LEFT JOIN `players` ON `players`.`id` = `player_deaths`.`player_id` WHERE `player_killers`.`player_id` = ' . $player->getId() . ' ORDER BY `date` DESC LIMIT 0,' . $frags_limit . ';')->fetchAll();
335+
if (count($player_frags)) {
336+
$row_count = 0;
337+
foreach ($player_frags as $frag) {
338+
$description = 'Fragged <a href="' . getPlayerLink($frag['name'], false) . '">' . $frag['name'] . '</a> at level ' . $frag['level'];
339+
$frags[] = array('time' => $frag['date'], 'description' => $description, 'unjustified' => $frag['unjustified'] != 0);
340+
}
341+
}
342+
}
343+
else if($db->hasTable('player_deaths') && $db->hasColumn('player_deaths', 'killed_by')) {
344+
$i = 0;
345+
$player_frags = PlayerDeath::where('player_deaths.killed_by', $player->getName())
346+
->join('players', 'players.id', '=', 'player_deaths.player_id')
347+
->limit($frags_limit)
348+
->selectRaw('players.name, player_deaths.*')
349+
->get();
350+
351+
if ($player_frags->count()) {
352+
$row_count = 0;
353+
foreach ($player_frags as $frag) {
354+
$description = 'Fragged <a href="' . getPlayerLink($frag->name, false) . '">' . $frag->name . '</a> at level ' . $frag->level;
355+
$frags[] = array('time' => $frag->time, 'description' => $description, 'unjustified' => $frag->unjustified != 0);
356+
}
336357
}
337358
}
338359
}

0 commit comments

Comments
 (0)