PDA

View Full Version : Got3n.com BF2 Stat Sigs


Got3n™
07-24-2005, 12:28 PM
Here is how to make em. This version im posting here is for the script from bf2s.com that was done by Jeff. I use the script..well sort of, its heavily modified but the principals are the same. Once you have a working version of his script installed on your website (requires php and mysql(preferable)) you just put this code into the correct files and it will work (99% sure).

This version is strickly text and dynamic rank image. No award/ribbons/stars/or pins, i will post those once i convert them from my version to the bf2s.com version. These scripts will run better if they are done with an sql database and I urge you to use it if you can, as to not spam EA. Out of the box, the script from bf2s.com does not work, it does not containg the "hack" to retrive stats still. If you do know it then your more than welcome to install the script and fix it. But i suggest doing the update time for 1 hour.

.htaccess stuff:

<Files nameofimageyouwanttouse.png>
ForceType application/x-httpd-php
</Files>


Actual image creation, i suggest making a text document on your desktop and calling it nameofimageyouwanttouse.png(same as above in .htaccess.

<?php
chdir('../..');
require('BF2Stats.php'); //required from the script to call the getStats from database

function DrawText($image,$color){
global $nickname,$score,$cmbscr,$tmscr,$acc,$kills,$death s,$joined,$lastbattle,$tttext,$killstr,$dthstr,$fa vkit,$favmap,$favveh,$favwea;
imagestring($image, 3, 60, 2, "$nickname", $color);
imagestring($image, 2, 75, 15, "Global Score: $score", $color);
imagestring($image, 2, 75, 28, "Combat Score: $cmbscr", $color);
imagestring($image, 2, 75, 41, "Team Score: $tmscr", $color);
imagestring($image, 2, 75, 54, "Kills(Strk): $kills ($killstr)", $color);
imagestring($image, 2, 75, 67, "Deaths(Strk): $deaths ($dthstr)", $color);
imagestring($image, 2, 75, 80, "Accuracy: $acc", $color);
imagestring($image, 2, 210, 2, "Enlisted: ".($joined['tm_year']+1900).'-'.substr('0'.($joined['tm_mon']+1),-2).'-'.substr('0'.$joined['tm_mday'],-2).' '.substr('0'.$joined['tm_hour'],-2).':'.substr('0'.$joined['tm_min'],-2), $color);
imagestring($image, 2, 210, 14, "Last Seen: ".($lastbattle['tm_year']+1900).'-'.substr('0'.($lastbattle['tm_mon']+1),-2).'-'.substr('0'.$lastbattle['tm_mday'],-2).' '.substr('0'.$lastbattle['tm_hour'],-2).':'.substr('0'.$lastbattle['tm_min'],-2), $color);
imagestring($image, 2, 210, 26, "Total Time: $tttext", $color);
imagestring($image, 3, 235, 39, "Favorites", $color);
imagestring($image, 2, 225, 50, "Kit: $favkit", $color);
imagestring($image, 2, 225, 61, "Map: $favmap", $color);
imagestring($image, 2, 225, 72, "Weapon: $favwea", $color);
imagestring($image, 2, 225, 83, "Vehicle: $favveh", $color);
imagestring($image, 3, 10, 84, "got3n.com", $color);
}//end of the function to draw the text on the image

$pid = 44474155;//set YOUR pid for the stats to be pulled from database, this can be dynamic and call any users stats, but for all intent purposes its just one user now, ill post the code for any user another day.
if( !$stats ) $stats = new BF2Stats();
if(!$stats->loadStats($pid)){
header("HTTP/1.0 404");
echo "Could not find specified file";
exit;
}//endif(!$stats->loadStats($pid))
chdir('images');

//Here it will check your rank and get the right png image to print, you will most likely have to change the image directory.
$rankimages=array("../bf2/resources/graphics/ranks/rank_0.png","../bf2/resources/graphics/ranks/rank_1.png","../bf2/resources/graphics/ranks/rank_2.jpg","../bf2/resources/graphics/ranks/rank_3.jpg","../bf2/resources/graphics/ranks/rank_4.jpg","../bf2/resources/graphics/ranks/rank_5.jpg","../bf2/resources/graphics/ranks/rank_6.jpg","../bf2/resources/graphics/ranks/rank_7.jpg","../bf2/resources/graphics/ranks/rank_8.jpg","ranks/sig/rank_9.jpg","ranks/sig/rank_10.jpg","ranks/sig/rank_11.jpg","ranks/sig/rank_12.jpg");
$rankimg=$stats->getStat('rank');

//Sets the variables for the draw text function
$nickname=$stats->getStat('nick');
$score=$stats->getStat('scor');
$cmbscr=$stats->getStat('cmsc');
$tmscr=$stats->getStat('twsc');
$acc=$stats->getStat('osaa');
$kills=$stats->getStat('kill');
$deaths=$stats->getStat('deth');
$joined=localtime($stats->getStat('jond',1),1);
$lastbattle=localtime($stats->getStat('lbtl',1),1);
$tttext=$stats->getStat('time');
$killstr=$stats->getStat('bksk');
$dthstr=$stats->getStat('wdsk');
$favmap=$stats->mapKey[$stats->getStat('fmap')];
$favveh=$stats->vehicleKey[$stats->getStat('fveh')];
$favkit=$stats->kitKey[$stats->getStat('fkit')];
$favwea=$stats->weaponKey[$stats->getStat('fwea')];

//Prints the Rank png image
$rankpart=imagecreatefrompng('../bf2/resources/graphics/ranks/rank_'.intval($rankimg).'.png');

//Creates the image background, this is the actual background(you will have to make this image yourself in photoshop or what ever and then put it on your server and put the appropriate URL)
$im = imagecreatefrompng('ranks/sig/rank.png');
imagecopy($im,$rankpart,-2,8,0,0,83,83);
imagedestroy($rankpart);


$imbackup=imagecreatetruecolor(400,100);
imagecopy($imbackup,$im,0,0,0,0,400,100);
$textholder=imagecreatefrompng('ranks/sig/rankclear.png');

imagedestroy($textholder);
$text_color=imagecolorallocate($im,0,0,0);

$text_color=imagecolorallocate($im,0,0,0);
imagecopymerge($im,$imbackup,0,0,0,0,400,100,50);
imagedestroy($imbackup);
DrawText($im,$text_color);

header("Content-type: image/png");
imagepng($im);
imagedestroy($im);

?>


Please excuse the messy code, i labled what i felt are the thing you needed to know. Any questions post them here.

Stay tuned for the code for other sigs like the ones i have below, there are 3 i have now, im working on the pins one to complete the set.

edit: bah after all that typing and copy and paste i didnt see the other sig generator post. ohh well this one uses the bf2s.com script.