
Code: Select all
|_n54__________________|_Ladder____________|_Matches___________|_Rounds____________|
| Breakfast | ###.### | ###.### | ###.### | ###.### | ###.### | ###.### |
Moderator: Lucifer
Code: Select all
|_n54__________________|_Ladder____________|_Matches___________|_Rounds____________|
| Breakfast | ###.### | ###.### | ###.### | ###.### | ###.### | ###.### |
For the first, set ts=off in the url and you got it. (Easy to addnemostultae wrote:I'd like it if I could get rid of text-shadow completly. Right now I have it set to the color of my background, but that did not get rid of it (can still see the blur). Also, if the position your are in ladder/matches/rounds could have a st, nd, rd, or th (1st, 2nd, 3rd, 4th) added, it would make reading the stats easier.
I meant to respond to this already. That's planned for after there's integration with the website and a happy UI to set config. The main issue here is font support. I see that ish has already done it with his, though....n54 wrote:very niceis there some way we could have a two lines version like this?
and could we define fonttype and size (i.e. capitalized and 10px)?Code: Select all
|_n54__________________|_Ladder____________|_Matches___________|_Rounds____________| | Breakfast | ###.### | ###.### | ###.### | ###.### | ###.### | ###.### |
I admit, ish, I couldn't handle sitting on code I wrote myself that I couldn't release. Have you checked out my aastats class? How easy would it drop into your stat generator to replace the one that you're unsure of the license? Not that many interfaces to Armagetron stats came to mind when I created that class, so it seems like it shouldn't be that hard.ishAdmin wrote:Yeah, I wanted to change it for ages, so n54's post prompted me to do that.
Code: Select all
<?php
//define some stuff here
$defaultplayername = "goggles"; //when no name is specified, use this
$server = "ARMAGOSHDARNISH in 2.6";
//$font = "slkscrb.ttf"; //full path to font name desired.
$font = "trebuchet.ttf"; //full path to font name desired.
// put any truetype font in the same dir/folder and use it.
$img_png = ""; // path or url to png file for background
$img_gif = "statsbackground.gif"; // path or url to gif file for background
$pathtotron = "yourpathtotrondata/"; // specify folder
//DO NOT EDIT BELOW THIS LINE
if (!$player)
$player = $defaultplayername;
// this is the class I can't release that lets me get stats. Luckily it was a class ! It only reads 2.6 style stats that are NOT tab delimited.
require_once( "class2.armagetronstats.php" );
$s = new CArmagetronStats( $pathtotron, 100 );
// also, that 100 only takes the first 100 IIRC. It should be upped's obviously.
$player = $_GET['p'];
$PlayerInfo = $s->GetPlayerInfo( $player );
//only use .gif at the moment, but it could be whatever if you change the next line appropriately. I was going to put in some code for this.
$img_number = imagecreatefromgif($img_gif);
// define some colours
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$grey_shade = imagecolorallocate($img_number,80,80,80);
$red = imagecolorallocate($img_number,200,0,0);
$yellow = imagecolorallocate($img_number,255,255,150);
// so here is where we pluck the stats out of the the array that used the class I can't release. Do whatever you want to get these stats.
$rankladder = $PlayerInfo['ladder'];
$rankmatch = $PlayerInfo['rankmatches'];
$rankround = $PlayerInfo['rankrounds'];
$scoreladder = $PlayerInfo['ladderscore'];
$scoreladder = round($scoreladder, 2); // I'm just rounding to 2 decimal places
$scorematch = $PlayerInfo['wonmatches'];
$scoreround = $PlayerInfo['wonrounds'];
// write in the stats we acquired into the image
Imagettftext($img_number, 11.5,0,60,15,$white,$font,$player);
Imagettftext($img_number, 8.5,0,60,26,$white,$font,$server);
Imagettftext($img_number, 9.5,0,215,26,$yellow,$font,"$rankladder/$scoreladder");
Imagettftext($img_number, 9.5,0,275,26,$yellow,$font,"$rankmatch/$scorematch");
Imagettftext($img_number, 9.5,0,333,26,$yellow,$font,"$rankround/$scoreround");
// send in the clowns
header("Content-type: image/png");
imagepng($img_number);
// image destroy to prevent memory leaks
imagedestroy($img_number);
// where are the clowns?
?>
Code: Select all
function ordinalize($num) {
if (!is_numeric($num))
return $num;
if ($num >= 11 and $num <= 19)
return $num."th";
elseif ( $num % 10 == 1 )
return $num."st";
elseif ( $num % 10 == 2 )
return $num."nd";
elseif ( $num % 10 == 3 )
return $num."rd";
else
return $num."th";
}
I am totally, madly, and passionately in love with the php manual because of the comments. I've found numerous time-saving functions and code snippets in there. The MySQL manual is less useful in that fashion, but the php manual is wonderful. I wish all online documentation had comments in them (specifically the wxWidgets and Python documentation). It's superior to wiki documentation, in my opinion, because it has the "official" documentation in plain view and then the unofficial stuff (even with comments from the php developers!) right there on the same page. It's like being able to look at amanual that everyone gets a chance to write their own notes in.ishAdmin wrote: PHP has this already built into the date function, but i couldn't find anything to format regular numbers in an ordinal format. I found this simple function in the comments at php.net.