mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-10-19 20:33:26 +02:00
Player history and powergamers rewrite
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
include 'layout/widgets/charactersearch.php';
|
||||
include 'layout/widgets/topplayers.php';
|
||||
include 'layout/widgets/highscore.php';
|
||||
if ($config['powergamers']['enabled']) include 'layout/widgets/powergamers.php';
|
||||
include 'layout/widgets/serverinfo.php';
|
||||
if ($config['ServerEngine'] !== 'TFS_02') include 'layout/widgets/houses.php';
|
||||
if ($follow["enabled"]): ?>
|
||||
|
@@ -22,6 +22,7 @@
|
||||
<li><a href="forum.php">Forum</a> </li>
|
||||
<li><a href="guilds.php">Guilds</a> </li>
|
||||
<li><a href="highscores.php">Highscores</a> </li>
|
||||
<?php if ($config['powergamers']['enabled']): ?><li><a href="powergamers.php">Powergamers</a> </li><?php endif; ?>
|
||||
<li><a href="houses.php">Houses</a> </li>
|
||||
<li><a href="killers.php">Killstatistics</a> </li>
|
||||
<li><a href="deaths.php">Latest deaths</a> </li>
|
||||
|
63
layout/widgets/powergamers.php
Normal file
63
layout/widgets/powergamers.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<div class="well widget">
|
||||
<div class="header">
|
||||
Top 5 Powergamers
|
||||
</div>
|
||||
<div class="body">
|
||||
<table>
|
||||
<?php
|
||||
$cache = new Cache('engine/cache/widget_powergamers');
|
||||
if ($cache->hasExpired()) {
|
||||
$players = mysql_select_multi("
|
||||
SELECT
|
||||
`h`.`player_id`,
|
||||
`p`.`name`,
|
||||
`p`.`level`,
|
||||
CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) AS `diff_experience`
|
||||
FROM (
|
||||
SELECT
|
||||
`i`.`player_id`,
|
||||
IFNULL(`o`.`id`, `i`.`id`) AS `from_id`
|
||||
FROM `player_history_skill` AS `i`
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
`x`.`player_id`,
|
||||
MAX(`x`.`id`) AS `id`
|
||||
FROM `player_history_skill` AS `x`
|
||||
WHERE
|
||||
`x`.`lastlogout` < UNIX_TIMESTAMP() - 7 * 24 * 60 * 60
|
||||
GROUP BY
|
||||
`x`.`player_id`
|
||||
) AS `o`
|
||||
ON `i`.`player_id` = `o`.`player_id`
|
||||
WHERE
|
||||
`i`.`lastlogout` >= UNIX_TIMESTAMP() - 7 * 24 * 60 * 60
|
||||
GROUP BY
|
||||
`i`.`player_id`
|
||||
) AS `h`
|
||||
INNER JOIN `player_history_skill` AS `f`
|
||||
ON `h`.`from_id` = `f`.`id`
|
||||
INNER JOIN `players` AS `p`
|
||||
ON `h`.`player_id` = `p`.`id`
|
||||
WHERE CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) > 0
|
||||
ORDER BY CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) DESC
|
||||
LIMIT 5
|
||||
");
|
||||
|
||||
$cache->setContent($players);
|
||||
$cache->save();
|
||||
} else {
|
||||
$players = $cache->load();
|
||||
}
|
||||
|
||||
if ($players) {
|
||||
foreach($players as $count => $player) {
|
||||
$nr = $count+1;
|
||||
$kexp = $player['diff_experience'] / 1000;
|
||||
$kexp = number_format($kexp, 0, '', ' ');
|
||||
echo "<tr><td>{$nr}</td><td><a href='characterprofile.php?name={$player['name']}'>{$player['name']}</a> ({$player['level']}) <span style='float: right;font-size:14px;'>{$kexp} K exp</span></td></tr>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user