|
8 | 8 | * @copyright 2019 MyAAC
|
9 | 9 | * @link https://my-aac.org
|
10 | 10 | */
|
| 11 | + |
| 12 | +use MyAAC\Models\PlayerDeath; |
| 13 | + |
11 | 14 | defined('MYAAC') or die('Direct access not allowed!');
|
12 | 15 | $title = 'Characters';
|
13 | 16 |
|
@@ -322,17 +325,35 @@ function retrieve_former_name($name)
|
322 | 325 |
|
323 | 326 | $frags = array();
|
324 | 327 | $frag_add_content = '';
|
325 |
| - if($config['characters']['frags'] && $db->hasTable('killers')) { |
326 |
| - //frags list by Xampy |
327 |
| - $i = 0; |
| 328 | + if ($config['characters']['frags']) { |
328 | 329 | $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 | + } |
336 | 357 | }
|
337 | 358 | }
|
338 | 359 | }
|
|
0 commit comments