Quote:
Originally Posted by picknroll
Is there anyway to display Top10 in server message of the day?
Or make the TOP10 Display when you first join the server?
|
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>#OilGaming 1v1</title>
<link href='https://fonts.googleapis.com/css?family=Oswald:400,700,300' rel='stylesheet' type='text/css'>
<style type="text/css">
body {
color: #ffffff;
padding: 0;
margin: 0;
height: 100%;
background: #000 url('img/background.jpg') center no-repeat fixed;
}
TD { color: #ffffff; }
.statstable {
bdackground: #aaaaaa;
background: url('img/bgtrans.png');
border-radius: 15px;
border: #000000 1px solid;
margin: 10px;
font-family: 'Oswald', sans-serif;
}
TD.stats { color: #000000; padding-left: 5px; padding-right: 5px;}
.sta3ts { background: url('img/bgtrans.png'); border-radius: 15px; border: #000000 1px solid; margin: 10px; font-family: 'Oswald', sans-serif; }
</style>
</head>
<body>
<TABLE align=center class=statstable>
<TR>
<TD width=300><img src="img/header.png"></TD>
<TD align=center>104.207.155.10:27015 -[US/CA]- *Arena 1v1* 128 Tick - OilGaming.com</TD>
</TR>
</TABLE>
<TABLE align=center style="background: url('img/bgtrans.png'); border-radius: 15px; border: #000000 1px solid; margin: 1px; font-family: 'Oswald', sans-serif; heighdt: 100%;" cellpadding=0 cellspacing=0>
<TR>
<TD class=stats>Rank</TD>
<TD class=stats>Player</TD>
<TD class=stats>Score</TD>
<TD class=stats>kills</TD>
<TD class=stats>deaths</TD>
<TD class=stats>K/D</TD>
<TD class=stats>Shots</TD>
<TD class=stats>Hits</TD>
<TD class=stats>Acc.</TD>
<TD class=stats>Headshots</TD>
<TD class=stats>Time Played</TD>
<TD class=stats>Last Connect</TD>
</TR>
<?php
function duration($seconds, $max_periods) {
$duration = '';
$periods = array('year' => 31536000, 'month' => 2419200, 'w' => 604800, 'd' => 86400, 'h' => 3600, 'm' => 60, 's' => 1);
$i = 1;
foreach ( $periods as $period => $period_seconds ) {
$period_duration = floor($seconds / $period_seconds);
$seconds = $seconds % $period_seconds;
if ( $period_duration == 0 ) continue;
$duration[] = $period_duration .''. $period . ($period_duration > 1 ? '' : '');
$i++;
if ( $i > $max_periods ) break;
}
if (is_null($duration)) return 'just now';
return @implode(' ', $duration);
}
$data = '';
$db = new SQLite3('INSERT YOUR OWN DIRECTORY HERE');
$sql = "SELECT * FROM players ORDER BY score DESC LIMIT 10";
$result = $db->query($sql);
$rank = 1;
while ($row = $result->fetchArray(SQLITE3_ASSOC)){
echo "\n <TR>";
echo "\n <TD class=stats align=right>".$rank.". </TD>";
$rank++;
echo "\n <TD class=stats title=\"".$row['steamid']."\">".$row['name']."</TD>";
echo "\n <TD class=stats>".(1000 + $row['score'])."</TD>";
echo "\n <TD class=stats>".$row['kills']."</TD>";
echo "\n <TD class=stats>".$row['deaths']."</TD>";
echo "\n <TD class=stats>".@round($row['kills'] / $row['deaths'],2)."</TD>";
echo "\n <TD class=stats>".$row['shots']."</TD>";
echo "\n <TD class=stats>".$row['hits']."</TD>";
echo "\n <TD class=stats>".@round($row['hits'] / $row['shots'] * 100,2)."%</TD>";
echo "\n <TD class=stats>".$row['headshots']." (".@round($row['headshots'] / $row['hits'] * 100,2)."%)</TD>";
echo "\n <TD class=stats>".duration($row['time_played'],3)."</TD>";
$timeFirst = strtotime($row['last_connect']);
$timeSecond = strtotime(date("Y-m-d h:i:s"));
$differenceInSeconds = $timeSecond - $timeFirst;
$differenceInSeconds -= 3600;
if ($differenceInSeconds > 60) {
echo "<TD class=stats style=\"color: #990000;\">".duration(($differenceInSeconds),3)." ago.</TD>";
} else {
echo "<TD class=stats style=\"color: #009900;\"><b>Online now!</b></TD>";
}
echo "\n </TR>\n";
}
unset($db);
?>
</TABLE>
</body>
</html>
Credits go to us at #OilGaming - If this code is put into a .php file on a webserver (on the same box the server is hosted on) it will show SQLite information in your MOTD, in the case that you assign this url to your motd.