Created
January 17, 2025 21:34
-
-
Save slawkens/62ee566f44be2f583a5266fd901c3f39 to your computer and use it in GitHub Desktop.
Powergamers from Gesior for MyAAC 0.8 and 1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('MYAAC') or die('Direct access not allowed!'); | |
$limit = 50; | |
$type = $_REQUEST['type'] ?? ''; | |
function coloured_value($valuein) | |
{ | |
$value = ''; | |
$value2 = $valuein; | |
while(strlen($value2) > 3) | |
{ | |
$value .= '.'.substr($value2, -3, 3); | |
$value2 = substr($value2, 0, strlen($value2)-3); | |
} | |
$value = $value2.$value; | |
if($valuein > 0) | |
return '<font color="green">+'.$value.'</font>'; | |
elseif($valuein < 0) | |
return '<font color="red">'.$value.'</font>'; | |
else | |
return '<font color="black">'.$value.'</font>'; | |
} | |
$playersOnline = []; | |
if($db->hasTable('players_online')) { | |
$query = $db->query('SELECT `player_id` FROM `players_online`')->fetchAll(PDO::FETCH_ASSOC); | |
foreach ($query as $player) { | |
$playersOnline[$player['player_id']] = true; | |
} | |
} | |
$deleted = 'deleted'; | |
if($db->hasColumn('players', 'deletion')) | |
$deleted = 'deletion'; | |
$addWhere = 'players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden']; | |
if(empty($type)) | |
$players = $db->query('SELECT * FROM ' . $db->tableName('players') . ' WHERE ' . $addWhere . ' ORDER BY ' . $db->fieldName('experience') . '-' . $db->fieldName('exphist_lastexp') . ' DESC LIMIT ' . $limit)->fetchAll(); | |
elseif($type == "sum") | |
$players = $db->query('SELECT * FROM ' . $db->tableName('players') . ' WHERE ' . $addWhere . ' ORDER BY ' . $db->fieldName('exphist1') . '+' . $db->fieldName('exphist2') . '+' . $db->fieldName('exphist3') . '+' . $db->fieldName('exphist4') . '+' . $db->fieldName('exphist5') . '+' . $db->fieldName('exphist6') . '+' . $db->fieldName('exphist7') . '+' . $db->fieldName('experience') . '-' . $db->fieldName('exphist_lastexp') . ' DESC LIMIT ' . $limit)->fetchAll(); | |
elseif($type >= 1 && $type <= 7) | |
$players = $db->query('SELECT * FROM ' . $db->tableName('players') . ' WHERE ' . $addWhere . ' ORDER BY ' . $db->fieldName('exphist' . (int) $type) . ' DESC LIMIT '.$limit)->fetchAll(); | |
echo '<CENTER><H2>Ranking of powergamers</H2></CENTER><BR><TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" WIDTH="100%"><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD style="color:white"><B>Rank</B></TD><TD style="color:white"><B>Name</B></TD>'; | |
if($type == "sum") | |
echo '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type=sum">7 Days sum</a></center></B></TD>'; | |
else | |
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type=sum">7 Days sum</a></center></B></TD>'; | |
for($i = 7; $i >= 2; $i--) | |
{ | |
if($type == $i) | |
echo '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>'; | |
else | |
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>'; | |
} | |
if($type == 1) | |
echo '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type=1">1 Day Ago</a></center></B></TD>'; | |
else | |
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type=1">1 Day Ago</a></center></B></TD>'; | |
if(empty($type)) | |
echo '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers">Today</a></center></B></TD>'; | |
else | |
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers">Today</a></center></B></TD>'; | |
echo '</TR>'; | |
$number_of_rows = 0; | |
foreach($players as $player) | |
{ | |
if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++; | |
echo '<tr bgcolor="'.$bgcolor.'"><td align="center">'.$number_of_rows.'. </td>'; | |
if(isPlayerOnline($player)) | |
echo '<td><a href="'.getPlayerLink($player['name'], false).'"><b><font color="green">'.htmlspecialchars($player['name']).'</font></b></a>'; | |
else | |
echo '<td><a href="'.getPlayerLink($player['name'] , false).'"><b><font color="red">'.htmlspecialchars($player['name']).'</font></b></a>'; | |
echo '<br />'.$player['level'].' '.htmlspecialchars($config['vocations'][$player['vocation']]).'</td><td align="right">'.coloured_value($player['exphist1'] + $player['exphist2'] + $player['exphist3'] + $player['exphist4'] + $player['exphist5'] + $player['exphist6'] + $player['exphist7'] + $player['experience'] - $player['exphist_lastexp']).'</td>'; | |
echo '<td align="right">'.coloured_value($player['exphist7']).'</td><td align="right">'.coloured_value($player['exphist6']).'</td><td align="right">'.coloured_value($player['exphist5']).'</td><td align="right">'.coloured_value($player['exphist4']).'</td><td align="right">'.coloured_value($player['exphist3']).'</td><td align="right">'.coloured_value($player['exphist2']).'</td><td align="right">'.coloured_value($player['exphist1']).'</td><td align="right">'.coloured_value($player['experience']-$player['exphist_lastexp']).'</td></tr>'; | |
} | |
echo '</TABLE>'; | |
function isPlayerOnline($player) { | |
global $db, $playersOnline; | |
if($db->hasTable('players_online')) { | |
return isset($playersOnline[$player['id']]); | |
} | |
return $player['online'] == 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment