d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1262728293060Next
Add Reply New Topic New Poll
Member
Posts: 1,909
Joined: May 8 2007
Gold: 2,507.26
Feb 26 2009 02:27am
I have PMed a moderator to edit my OP. Alot of people are having problems with

Code
Options MultiViews


a general solution will hopefully be added to the start post very soon.
Member
Posts: 19,516
Joined: Dec 26 2007
Gold: 264.04
Feb 26 2009 04:52pm
http://www.p00npie.com/ls/T3H-iNub2.png/

why does that not work? it doens't work on my purchased server but it used to work on freehostia, same code...

Code

<?php
Header ('Content-type: image/png');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

/******************************************************
*                     BASICS                         *
******************************************************/

// set some dimensions for future use
$expbar_width = 100;
$expbar_height = 20;

// create the image from a background jpg
$image = imagecreatefrompng('BG.PNG');

// set some colours for future use
$black  = imagecolorallocate($image, 0, 0, 0);
$red   = imagecolorallocate($image, 255, 0, 0);
$blue = imagecolorallocate($image, 0, 0, 255);

// set the background colour
// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

// set the font and print text
$font = '/public_html/ls/arial.ttf';

/******************************************************
*                     LOAD DATA                      *
******************************************************/

// Create an array for determining the class you play.
// In the XML this is saved as an int number, the conversion is shown below.
$class_name = array(   -1 => 'None',
   0 => 'Fighter',
   1 => 'Barbarian',
   2 => 'Rogue',
   3 => 'Magician',
4 => 'Guardian',
   5 => 'Samurai',
   6 => 'Paladin',
   7 => 'Monk',
   8 => 'Ninja',
   9 => 'Warlock',
   10 => 'Headhunter',
   11=> 'Alchemist');

// load xml data in vars

// This is where you load your own info from the xml d2jsp gives. This is a PHP5 only command!
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=195447');
$name = $data->name;
$kills = $data->kills;
$class = $class_name[(int)$data->classid];
$exp = $data->exp;
$level = $data->level;
$hpmax = $data->hpmax;
$mqpasses = $data->mqpasses;
$mqattempts = $data->mqattempts;
$exp = (int)$exp;
$percent = calcExpPercent($exp);
$brpixelX = calcBrPixelX($exp,$expbar_width);

// Create an expbar with bg 'cool' color and the cover of your level in red.
imagefilledrectangle($image, 120, 9, 124, 19, $black);
imagefilledrectangle($image, 120, 9, $brpixelX, 19, $red);


/******************************************************
*                     TEXT PART                      *
******************************************************/

//Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color, font, "text");

// EXP bar text
ImageTTFText ($image, 9, 0, 90, 19, $red, $font, "EXP: ");
ImageTTFText ($image, 9, 0, 160, 19, $black, $font, $percent."%");

//show name
ImageTTFText ($image, 9, 0, 90, 33, $black, $font, "Name: ");
ImageTTFText ($image, 9, 0, 129, 33, $red, $font, $name);

//show class
ImageTTFText ($image, 9, 0, 157, 33, $black, $font, "Class: ");
ImageTTFText ($image, 9, 0, 197, 33, $red, $font, $class);

// show lvl
ImageTTFText ($image, 9, 0, 90, 45, $yellow, $font, "Level: ");
ImageTTFText ($image, 9, 0, 125, 45, $red, $font, $level);

//show experience
ImageTTFText ($image, 9, 0, 145, 45, $black, $font, "Experience: ");
ImageTTFText ($image, 9, 0, 215, 45, $red, $font, $exp);

// show kills
ImageTTFText ($image, 9, 0, 312, 45, $yellow, $font, "Kills: ");
ImageTTFText ($image, 9, 0, 352, 45, $red, $font, $kills);

// Show HP max
ImageTTFText ($image, 9, 0, 90, 57, $yellow, $font, "HP: ");
ImageTTFText ($image, 9, 0, 113, 57, $red, $font, $hpmax);

// SHow MQ passen and attempts
ImageTTFText ($image, 9, 0, 144, 57, $black, $font, "MQ passes/attempts: ");
ImageTTFText ($image, 9, 0, 261, 57, $red, $font, $mqpasses."/".$mqattempts);

// Show useless shizzle
ImageTTFText ($image, 9, 0, 107, 71, $yellow, $font, "-------------------------------------");
ImageTTFText ($image, 14, 0, 116, 89, $red, $font, "Urge2Kill - T3H");

// output and destroy
Header ('Content-type: image/png');
imagedestroy($image);


/******************************************************
*                     FUNCTIONS                      *
******************************************************/

/***
* calculate the exp bar width.
***/
function calcBrPixelX($input,$xpbar_width)
{
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * $xpbar_width;
$temp1 = $temp1 + 180;

return (int)$temp1;
}

/***
* Calculate the percentage of level done
***/
function calcExpPercent($input)
{
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * 100;

return (int)$temp1;
}

?>
Member
Posts: 2,677
Joined: Jun 16 2006
Gold: 6.00
Feb 26 2009 06:47pm
T3H, When I look at the page, the first warning I get is

Code
<b>Warning</b>:  imagecreatefrompng(bg.png) [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: failed to open stream: No such file or directory in <b>/home/pnpiecom/public_html/ls/T3H-iNub2.png/index.php</b> on line <b>16</b><br />


That might have something to do with it. Check to make sure bg.png exists in the proper location.
Member
Posts: 2,272
Joined: Feb 27 2009
Gold: 810.40
Mar 1 2009 08:37pm
I'll try this when I wake up biggrin.gif THX! heart.gif =D
Member
Posts: 1,909
Joined: May 8 2007
Gold: 2,507.26
Mar 3 2009 06:31am
also make sure that BG.PNG is typed in capital in your filedir. Since you have it that way in your code.

Next it might have something to do with the

Code
options multiviews


Your can easily try another method which works more often (wanted to add this in the OP)

change in your .htaccess

Code
Options Multiviews


to

Code
RewriteEngine On
RewriteRule T3H-iNub2.png T3H-iNub2.php5


and also rename your:

T3H-iNub2.png.php5 icon_pointr.gif T3H-iNub2.php5
Member
Posts: 8,800
Joined: Nov 8 2006
Gold: 650.66
Mar 4 2009 12:21pm
THX flap for making the sig work again; keep up the GOOD work bier.gif hug.gif
Member
Posts: 27,083
Joined: Apr 20 2008
Gold: 2,992.30
Mar 7 2009 04:45pm
Wow Gz.

Thats insane.
Member
Posts: 53,371
Joined: Jun 8 2007
Gold: 87,899.45
Mar 7 2009 05:10pm
tyvm i will try it too smile.gif
Member
Posts: 9,395
Joined: Aug 9 2007
Gold: 0.02
Mar 25 2009 06:29pm
anyone want to help me learn this? im stick on step one....im very bad with codings and things lol.
Member
Posts: 5,053
Joined: Jul 3 2006
Gold: 198.86
Apr 3 2009 07:50pm
Thanks for the guide. I can understand it well.

I have one question though.

Can I use a jpg file or bmp even? When I try to use a png file, it is too big to use for sigs on JSP, but when I try png-8, the quality sucks.
Go Back To Ladder Slasher Topic List
Prev1262728293060Next
Add Reply New Topic New Poll