Help with my site

Post here if you need help setting up your server, etc.
Post Reply
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Help with my site

Post by Aang (avatar fan) »

Help please.

In norms place and other server sites, there is some scripting that tells who is playing, and the ladder, how do you do this?

Please help. :?:
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

No one?
User avatar
philippeqc
Long Poster - Project Developer - Sage
Posts: 1526
Joined: Mon Jul 12, 2004 8:55 am
Location: Stockholm
Contact:

Post by philippeqc »

It must be a script that read the logs/stats from the game.

Check the wiki and search the forums.

-ph

PS: Dont be like that. Not everybody check the forum everyday. If your message goes unnoticed for a week, then post a gentle reminder. If you need something now, the forum is the wrong media, and you should try IRC.
Canis meus id comedit.
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

Ok sorry, i am new to this.

Thanks i'll check the wiki.
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

No sorry

Checked the wiki but i can't anything. Maybe norm from norms place knows.
User avatar
Sylv
On Lightcycle Grid
Posts: 39
Joined: Sun Sep 05, 2004 4:16 pm

Post by Sylv »

below is the code of a simplified version of chibi t's ladderscript
(found it here: http://sourceforge.net/tracker/index.ph ... tid=306185)
i have used this on my own servers, it's still in use on angels servers. and others.
see the script in action:
http://angeltron.game-host.org/durka.php
or
http://thelbx.com/ladder/


you need two files on your (web)server, stats.php and overall.pl
the perl script generates the output for the html-table.

code for stats.php:

Code: Select all

<html>
<head>
<title></title>
</head>
<body>
<?php

// start configuration
$scriptdir = "/var/www/web1/html/cgi-bin"; //absolute location of overall.pl
$statsdir = "/server1/var"; // absolute location of highscores.txt, players.txt, etc.
$max_items = 101; // max_items = number of rows +1 defaults to the "top 100"
// end configuration

$list="";
$counter=0;
      $fileonline = fopen($statsdir . "/players.txt", "r");
        while(!feof($fileonline)) {
          $counter++;
          $online = fgets($fileonline, 4096);
          $playername = substr($online, 0, 16);
          if($counter != 1) {
            if($playername > "") {
              $list=$list."<li>".$playername."</li>\n";
              }
             }
           }
      fclose($fileonline);
          if($counter > 2) {
echo "<ul>";
echo $list;
echo "</ul>";
}
else
 {
echo "nobody online.";
}
?>
<table border=1>
  <tr>
    <td>no.</td>
    <td><a href=<? $_SERVER["SCRIPT_NAME"] ?>"?orderby=name">name</a></td>
    <td><a href=<? $_SERVER["SCRIPT_NAME"] ?>"?orderby=rating">rating</a></td>
    <td><a href=<? $_SERVER["SCRIPT_NAME"] ?>"?orderby=matches">won matches</a></td>
    <td><a href=<? $_SERVER["SCRIPT_NAME"] ?>"?orderby=rounds">won rounds</a></td>
    <td><a href=<? $_SERVER["SCRIPT_NAME"] ?>"?orderby=score">single player highscore</a></td>
  </tr>
<?php
if(isset($_GET['orderby'])){
$orderby = $_GET['orderby'];
} else {
$orderby = "rating";
}
echo `$scriptdir/overall.pl $statsdir $orderby $max_items`;
?>

</table>
</body>
</html>
code for overall.pl

Code: Select all

#!/usr/bin/perl
my $armadir = shift || "/home/armagetronad/.armagetronad/var/";
my %players;
my $orderby = shift || "rating";
my $max_items = shift || 101;

open PLAYERS, $armadir . "/ladder.txt";
my @rawladder = <PLAYERS>;
close PLAYERS;
foreach my $player (@rawladder)
{
	(my($rating), my($name)) = ($player =~ /^([-0-9.]+)\s*(.*$)/gio);
	$players{$name}->{'name'} = $name;
	$players{$name}->{'rating'} = $rating;
}
open PLAYERS, $armadir . "/highscores.txt";
my @rawscores = <PLAYERS>;
close PLAYERS;
foreach my $player (@rawscores)
{
	(my($score), my($name)) = ($player =~ /^([-0-9.]+)\s*(.*$)/gio);
	$players{$name}->{'name'} = $name;
	$players{$name}->{'score'} = $score;
}
open PLAYERS, $armadir . "/won_matches.txt";
my @rawmatches = <PLAYERS>;
close PLAYERS;
foreach my $player (@rawmatches)
{
	(my($matches), my($name)) = ($player =~ /^([-0-9.]+)\s*(.*$)/gio);
	$players{$name}->{'name'} = $name;
	$players{$name}->{'matches'} = $matches;
}
open PLAYERS, $armadir . "/won_rounds.txt";
my @rawrounds = <PLAYERS>;
close PLAYERS;
foreach my $player (@rawrounds)
{
	(my($rounds), my($name)) = ($player =~ /^([-0-9.]+)\s*(.*$)/gio);
	$players{$name}->{'name'} = $name;
	$players{$name}->{'rounds'} = $rounds;
}

my @ordered;
if ($orderby eq "name") {
	@ordered = sort {lc($a->{$orderby}) cmp lc($b->{$orderby})} values %players;
}
else {
	@ordered = sort {$b->{$orderby} <=> $a->{$orderby}} values %players;
}

my $i = 1;
foreach my $player (@ordered)
{
last if $i == $max_items; 
	print  "  <tr>\r\n";
	print  "    <td>" . $i++ . "</td>\n";
	print  "    <td>" . $player->{'name'} . "</td>\r\n";
	print  "    <td>" . $player->{'rating'} . "</td>\r\n";
	print  "    <td>" . $player->{'matches'} . "</td>\r\n";
	print  "    <td>" . $player->{'rounds'} . "</td>\r\n";
	print  "    <td>" . $player->{'score'} . "</td>\r\n";
	print  "  </tr>\r\n";

}
have fun ;)
Image
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

Thanks A LOT!

luv u luv u! :lol: :D :) 8) :wink: :mrgreen: :goatee: :stubble: :star: :pacman: :sdot: :sdot: :sdot: :!: :!: :!:

Thanks!

Just wondered, is the stats who is playing and their stats?

Again Thanks.
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

Hang on, it doesn't work.

I pasted the script into my document, but it only comes up with a lot of nonsense. The table works but inside the cells, well...
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Aang (avatar fan) wrote:...my document...
Which document???? Those are the contents of individual files, I guess you're supposed to put them all into a directory on your web server.
User avatar
Aang (avatar fan)
Round Winner
Posts: 210
Joined: Tue Apr 03, 2007 1:44 pm
Location: Far away, in a distant fantasy land, where there lives happly little elves. (I'm not one).
Contact:

Post by Aang (avatar fan) »

Oh i get it, but then how do they work.
I just put them into files and a table an my ladders.html page will just agically pop up?
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

I guess you'll have to point your browser to http://your.server.name/path/to/files/stats.php, this in turn will invoke the perl script, and all will read the score data from your server. The server data directory needs to be readable by the web server.

Ah, it looks like you have to adapt the $scriptdir and $statsdir variables to your configuration, too.
Post Reply