Breakfast Stat Sig for Players

Mmmm... What's cookin in the kitchen?

Moderator: Lucifer

User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

very nice :D is there some way we could have a two lines version like this?

Code: Select all

|_n54__________________|_Ladder____________|_Matches___________|_Rounds____________|
| Breakfast            | ###.### | ###.### | ###.### | ###.### | ###.### | ###.### |
and could we define fonttype and size (i.e. capitalized and 10px)?
User avatar
dlh
Formerly That OS X Guy
Posts: 2035
Joined: Fri Jan 02, 2004 12:05 am
Contact:

Post by dlh »

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. :wink:
User avatar
Lucifer
Project Developer
Posts: 8750
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

nemostultae 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. :wink:
For the first, set ts=off in the url and you got it. (Easy to add :) )

For the second, that'll have to wait until font support, although it's probably pretty easy to add (check the ones place and add the appropriate suffix). We'll quickly hit space problems if I try to add it now, without font support.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Lucifer
Project Developer
Posts: 8750
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

n54 wrote:very nice :D is there some way we could have a two lines version like this?

Code: Select all

|_n54__________________|_Ladder____________|_Matches___________|_Rounds____________|
| Breakfast            | ###.### | ###.### | ###.### | ###.### | ###.### | ###.### |
and could we define fonttype and size (i.e. capitalized and 10px)?
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....
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

Yeah, I wanted to change it for ages, so n54's post prompted me to do that.
Image
User avatar
Lucifer
Project Developer
Posts: 8750
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

ishAdmin wrote:Yeah, I wanted to change it for ages, so n54's post prompted me to do that.
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.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

Yeah, ok, since I've dug into this yesterday and today, when I really have better things to do, well here it goes. :)

I haven't look at your class because I don't run 2.7. I'm not sure if yours reads 2.6 stats as well, I thought it didn't. So instead, take my code and change it.

This isn't finished. I was going to put code in for different image types, only half written, so it might look goofy and aimless and sloppy.

And because this is really simple stuff, no need to gpl it. Just take it baby!

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?
?>
Image
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

And someone wanted to have 1st, 2nd, 3rd, 4th etc. in the format of the rank. Here's a simple ordinalize function: (if ordinalize is a word)

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";
}
then just take you number and use this function on it.

ex.

$number = 21;

echo ordinalize($number);

outputs 21st.

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.
Image
User avatar
Lucifer
Project Developer
Posts: 8750
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

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.
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.

And thanks for the code, ish. I'm going to use it as positive reinforcement to get me to finish my other work, since I'm having a hard time motivating myself to work right now.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

Yeah, i'm with you on that Lucifer about the comments at php being top notch. Whenever I'm looking at the docs, I actually head straight for the comments. I start at the bottom and read up. It often goes right through the same thinking process I take on learning something new. I see some guy do something wrong, and another guy piping and saying, hey that doesn't work in this case. Superb stuff!
Image
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

I don't have any power but if I did i'd like to push for this:

all of you people who are doing valuable but not directly embedded code (Tank, Lucifer, ishAdmin & others too i bet) should really get lasting recognition

it's not at the core of the game but it absolutely increases the appeal of the game for a lot of players

you've all individually spent time figuring out various ways to solve various (and sometimes overlapping) pieces of both different forms of stats-to-html generating and automated signature stats creating etc.

My point is that I really really think you guys should make a sourceforge subproject or additional project on these issues and link to it from the armagetron/ad pages as well as this forum because i think a lot of server admins as well as players would love this stuff already, and even more so as it progresses in the future

and no it doesn't have to be a single solution fits all at all, having multiple solutions is a good thingTM but I still think it would be an advantage to collect all of them under an umbrella project and for that matter cooperate across solutions (and specificlly on those parts that require some sort of interoperability)

just my 0.00002 gold nuggets :goatee:

oh and i know how damned hard it is to release code one considers incomplete or unpolished or possibly even stupid, also how hard it is to release total control when one has the ability to follow ones own pace and not care about any kind of development bureaucracy. i'm not the right person to argue against any of those feelings but i think you're better than me and that you could all agree when making this umbrella project not to care about any of that stuff.

of course everything in this post might be totally wrong, it just seems like an idea whose time has come.... feel free to smack me with a spongebat if i'm delirious :D

and yeah the php-manual solution is super
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

kinda fun getting the sig to work :D
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

gee, i like your stats image n54. nice piggy!

I suppose the AA project on source forge itself could have these extras published under it. I agree they would be appreciated by some. But I don't personally want/need any credit for what I've released so far. It's really nothing of consequence, coding wise.
Image
User avatar
Lucifer
Project Developer
Posts: 8750
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Ok ish, I used your code to straighten out how to use ttf fonts and added font support. :) Thank you very much! :)

Sometime soon I'll go ahead and add the ability to display the thing horizontally like n54 asked, and then I'll want to get your font + background pic and try to use them as proof-of-concept for flexibility of the script. :)

I went ahead and added font support without doing the website integration job I was going to do because that would have wound up mixing too many problems up together.

I was going to lock this thread, and then realized there's more talking in here than just the statsig, so would y'all mind moving any further statsig conversation to the new thread I created? (This one had enough discussion I felt it better to start a new thread)
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
Post Reply