d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1232425262760Next
Add Reply New Topic New Poll
Member
Posts: 4,923
Joined: Jan 9 2008
Gold: 0.50
Jan 23 2009 01:23pm
thanks for the guide!
Member
Posts: 34,410
Joined: Feb 2 2006
Gold: 0.00
Jan 24 2009 05:20am
Alright so my sig doesn't load really.
http://derfana.site90.com/sig/bg.png.php5

But I have noticed that a lot of other sigs that are hosted on this site don't load either. Anybody know if there is a way to fix this or is it actually my fault because I did something wrong?
I have these files in the sig folder:
.htaccess
bg.png,php5
bg.png
and the font
Member
Posts: 9,194
Joined: Jul 22 2007
Gold: 13.37
Jan 24 2009 08:07am
Quote (derfana @ Sat, 24 Jan 2009, 15:20)
Alright so my sig doesn't load really.
http://derfana.site90.com/sig/bg.png.php5

But I have noticed that a lot of other sigs that are hosted on this site don't load either. Anybody know if there is a way to fix this or is it actually my fault because I did something wrong?
I have these files in the sig folder:
.htaccess
bg.png,php5
bg.png
and the font

Works fine for me. Atm site under admin review.
Try rename from bg.png.php5 to bg.png.php

Member
Posts: 34,410
Joined: Feb 2 2006
Gold: 0.00
Jan 24 2009 09:16am
Quote (STM704 @ Sat, 24 Jan 2009, 15:07)
Works fine for me. Atm site under admin review.
Try rename from bg.png.php5 to bg.png.php


Nah, it's still the same.
Btw: my current sig and the one I made are on the same server but under different user domains(?). Both of them don't work. I'm guessing I'll just wait a day or so before I search the code for shit that's probably not even there. Because I really think that i didn't screw it up.
Member
Posts: 34,410
Joined: Feb 2 2006
Gold: 0.00
Jan 25 2009 10:25am
Changed the server but it still doesn't work really. the pic just won't load

http://derfana.110mb.com/bg.png.php5

Does anybody see any screw-ups in the code?
Code
<?php
Header ('Content-type: image/jpeg');
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 = 50;
$expbar_height = 8;

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

// set some colours for future use
$cool  = imagecolorallocate($image, 255, 255, 255);
$black   = imagecolorallocate($image, 0, 0, 0);
$yellow = imagecolorallocate($image, 255, 181, 53);

// 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 = '/copperplate.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=194766');
$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, 43, 83, 93, 91, $black);
imagefilledrectangle($image, 43, 83, $brpixelX, 91, $cool);


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

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

// EXP bar text
// ImageTTFText ($image, 7, 0, 122, 69, $cool, $font, "To Level: ");
//ImageTTFText ($image, 7, 0, 220, 69, $cool, $font, $percent."%");

//show name
// ImageTTFText ($image, 7, 0, 122, 33, $cool, $font, "HC Name: ");
ImageTTFText ($image, 7, 0, 43, 42, $cool, $font, $name);

//show class
// ImageTTFText ($image, 7, 0, 42, 33, $cool, $font, "Class: ");
ImageTTFText ($image, 7, 0, 54, 42, $coolk, $font, $class);

// show lvl
ImageTTFText ($image, 7, 0, 61, 42, $cool, $font, "Level: ");
ImageTTFText ($image, 7, 0, 61, 62, $cool, $font, $level);

//show experience
// ImageTTFText ($image, 7, 0, 180, 45, $yellow, $font, "Experience: ");
// ImageTTFText ($image, 7, 0, 250, 45, $black, $font, $exp);

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

// Show HP max
// ImageTTFText ($image, 7, 0, 122, 57, $yellow, $font, "HP: ");
// ImageTTFText ($image, 7, 0, 145, 57, $black, $font, $hpmax);

// SHow MQ passen and attempts
ImageTTFText ($image, 7, 0, 69, 42, $cool, $font, "MQ: ");
ImageTTFText ($image, 7, 0, 69, 49, $cool, $font, $mqpasses."/".$mqattempts);

// output and destroy
imagepng($image);
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;
}

?>



also: what img file would I have to link to?


Files in the folder:
bg.png.php5
bg.png
font
.htaccess

This post was edited by derfana on Jan 25 2009 10:25am
Member
Posts: 4,969
Joined: Feb 19 2007
Gold: 159.28
Jan 25 2009 10:53am
try to rename your bg.png.php5 to der.png.php

and then opening der.png
Member
Posts: 1,909
Joined: May 8 2007
Gold: 2,507.26
Jan 25 2009 12:18pm
You have to load the



http://derfana.110mb.com/bg.png

not the

http://derfana.110mb.com/bg.png.php5

It works here.

ALso, rename your bg image so it does not have the same name as your php file with .png.php since it will not know what to chose in the case they are the same.

This post was edited by flapmo on Jan 25 2009 12:20pm
Member
Posts: 17,336
Joined: Oct 3 2006
Gold: 78,990.00
Warn: 10%
Jan 25 2009 04:34pm
Quote (derfana @ Sun, 25 Jan 2009, 18:25)
http://derfana.110mb.com/bg.png.php5

i know this hosting. if you didn't pay for it you can't make "Dynamic Ladder-slasher Sig" (lol, it isn't dynamic ^^) using it.

test this:
Code
<?
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=194766');

echo "<pre>";
var_dump($data);
echo "</pre>";
?>

if you'll get such text:
Quote
Warning: simplexml_load_file() [function.simplexml-load-file]: URL file-access is disabled in the server configuration
- stop trying wink.gif
Member
Posts: 16,992
Joined: Apr 26 2008
Gold: 11,760.00
Jan 25 2009 04:44pm
Im having trouble with the colour of my text
I copied the code given to us and put it in the directory with the .htaccess file and 3 fonts
I then put in my own background and moved the name tag
Changed its fonts and its colours
The fonts work fine but none of the colours work, they always come out as a sort of yellow.



Code
<?php
Header ('Content-type: image/jpeg');
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 = 25;

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

// set some colours for future use
$brown  = imagecolorallocate($image, 202, 155, 95);
$pink   = imagecolorallocate($image, 255, 48, 62);
$purple = imagecolorallocate($image, 37, 10, 89);

// 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
$number = '/avqest.ttf';
$namefont = '/yum.ttf';
$font = '/alien.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=189900');
$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, 180, 59, 280, 71, $brown);
imagefilledrectangle($image, 180, 59, $brpixelX, 71, $purple);


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

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

// EXP bar text
ImageTTFText ($image, 9, 0, 122, 69, $yellow, $font, "To Level: ");
ImageTTFText ($image, 9, 0, 220, 69, $yellow, $font, $percent."%");

//show name
ImageTTFText ($image, 12, 0, 67, 21, $pink, $namefont, "Name");
ImageTTFText ($image, 12, 0, 99, 21, $purple, $font, ": ".$name);

//show class
ImageTTFText ($image, 9, 0, 280, 33, $yellow, $font, "Class: ");
ImageTTFText ($image, 9, 0, 320, 33, $red, $font, $class);

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

//show experience
ImageTTFText ($image, 9, 0, 180, 45, $yellow, $font, "Experience: ");
ImageTTFText ($image, 9, 0, 250, 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, 122, 57, $yellow, $font, "HP: ");
ImageTTFText ($image, 9, 0, 145, 57, $red, $font, $hpmax);

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

// output and destroy
imagepng($image);
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: 16,992
Joined: Apr 26 2008
Gold: 11,760.00
Jan 28 2009 02:50am
Still having trouble with colours O.o
This time the sig is coming up with red text O.o
Go Back To Ladder Slasher Topic List
Prev1232425262760Next
Add Reply New Topic New Poll