§ September 21, 2005
A Battlefield 2 Rank Avatar Script in PHP
This is a little departure from my typical topic.
To cut a rather tedious and boring story short, I play Battlefield 2, which has a cool stats service that folks have been hacking with outside of the game (the game has a stats board built in, which stats board uses some pseudo web-services to obtain game statistic info).
There are a multitude of server hosts out there that generate dynamic signature images with your game stats in them, so that you can look cool and show off how much time you actually waste online gaming, on every forum you frequent.
I decided to join the masses and write a script that pulls my users rank and score from the stats servers and returns an image that can be used as an avatar on most bulletin board systems out there. I had a size restriction on the server I wanted it for, so the images produced are 80x80 and less than 6k in size.
Using the avatar script is pretty easy, you direct the image source url to the server where you install the script (or you can just use the one here)
most bulliten board systems have places for you to link in a remote avatar, and one would add this same url w/ a name just as you would a normal image.
One annoying thing about most bbcode systems is that they require a valid image extension (.png, .jpg, .gif ... ) on the url inside the [img][/img] blocks (otherwise it just shows text inside the img blocks). To get your rank image to show up if you're having troubles is to simply add an &avatar.jpg to the end of the url. The php code will ignore it, and the forum will think its a valid image and will show it correctly. Another way is to use the simple url described in the forums here.
The resulting image looks like this:
You can also specify a couple of options.
EDIT Feb. 15 2006: since the last patch, I havent updated this article source code. HERE'S the most recent version of the script. you can download the package and copy that over the script provided.
EDIT March 20 2006: I updated the code to include nick name resolution (using searchforplayers.aspx). the link to the code above has that change in it. so you can use your player nick again instead of trying to find out your player ID.
EDIT June 30 2006: I removed the source code from the article and repacked the download with everything you need.
EDIT July 18 2006: I've added "easy url's" for the rank avatars. for more info on that--and if you'd like to add them to your server--take a look at the thread in the forums here.
Here's the code for the script (the download has a true type font that needs to be located in the script dir w/ all the image files which are also referenced, so make sure to download the script pack):
Download source and resources here.
This is a little departure from my typical topic.
To cut a rather tedious and boring story short, I play Battlefield 2, which has a cool stats service that folks have been hacking with outside of the game (the game has a stats board built in, which stats board uses some pseudo web-services to obtain game statistic info).
There are a multitude of server hosts out there that generate dynamic signature images with your game stats in them, so that you can look cool and show off how much time you actually waste online gaming, on every forum you frequent.
I decided to join the masses and write a script that pulls my users rank and score from the stats servers and returns an image that can be used as an avatar on most bulletin board systems out there. I had a size restriction on the server I wanted it for, so the images produced are 80x80 and less than 6k in size.
Using the avatar script is pretty easy, you direct the image source url to the server where you install the script (or you can just use the one here)
html <img src="http://www.sanity-free.org/bf2rank/?pid=45647367"> bbCode [img]http://www.sanity-free.org/bf2rank/?nick=[OinK]_MadHatter[/img]
most bulliten board systems have places for you to link in a remote avatar, and one would add this same url w/ a name just as you would a normal image.
One annoying thing about most bbcode systems is that they require a valid image extension (.png, .jpg, .gif ... ) on the url inside the [img][/img] blocks (otherwise it just shows text inside the img blocks). To get your rank image to show up if you're having troubles is to simply add an &avatar.jpg to the end of the url. The php code will ignore it, and the forum will think its a valid image and will show it correctly. Another way is to use the simple url described in the forums here.
The resulting image looks like this:
You can also specify a couple of options.
- adding &score will display your global score at the top of the image.
ex: - adding &no_text to the end of the url will keep the text from
being written on the image.
ex: - adding &delta to the end will show the difference in your progress between your last rank and your next one.
ex: - you can also combine any combination of them as well (this one is using &delta, &no_text, and &score options).
ex:
EDIT Feb. 15 2006: since the last patch, I havent updated this article source code. HERE'S the most recent version of the script. you can download the package and copy that over the script provided.
EDIT March 20 2006: I updated the code to include nick name resolution (using searchforplayers.aspx). the link to the code above has that change in it. so you can use your player nick again instead of trying to find out your player ID.
EDIT June 30 2006: I removed the source code from the article and repacked the download with everything you need.
EDIT July 18 2006: I've added "easy url's" for the rank avatars. for more info on that--and if you'd like to add them to your server--take a look at the thread in the forums here.
Here's the code for the script (the download has a true type font that needs to be located in the script dir w/ all the image files which are also referenced, so make sure to download the script pack):
Download source and resources here.
Posted 20 years, 8 months ago on September 21, 2005
Re: A Battlefield 2 Rank Avatar Script in PHP [ posted May 17, 2006, 3:56 am ]
Author | Comment |
---|---|
is it possible to include backround image? I mean that bgimage has only this rank image and rankname on it. [ Reply in the Forums ] |
Re: A Battlefield 2 Rank Avatar Script in PHP [ posted May 17, 2006, 8:59 am ]
Author | Comment | |||
---|---|---|---|---|
|
yes, you can use other images. I only intended this to be a small avatar, but one could easily make it a full blown stats image. we get most all the players stats in the query to EA, so adding other images, or text is fairly straight forward. for this script I have all my images named "rank_#.jpg" where the # indicates the numeric rank level that gets returned from the stats query (like rank_8.jpg), and the line where I get the image file I want to use is: so if you wanted to use another image you'd simply add some switch statement based on rank like: switch($rank_val) { and so on. [ Reply in the Forums ] |
© 2003 - 2024 NullFX