d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1414243444560Next
Add Reply New Topic New Poll
Member
Posts: 14,313
Joined: Jun 3 2007
Gold: 5,850.00
Jun 5 2009 06:53am
the cprofs are mapped in your code so wild heal would be:

$cprof["wildheal"]

for the easy way remove that line:
$cpname = $cpn[(int)$cpname];

and than $cprof[5] should work
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jun 5 2009 07:07am
same as for wprof if i make the same lines of code? probably :)

thanks again guMKa
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jun 5 2009 08:37am
to bad :(

i get a result of: 0 each time i try putting in $cprof[wildheal] or focusedheal
and i get no result when i remove the one line and try [5]

:(
Member
Posts: 14,313
Joined: Jun 3 2007
Gold: 5,850.00
Jun 5 2009 08:53am
Quote (coldguy @ Fri, 5 Jun 2009, 16:37)
to bad :(

i get a result of: 0 each time i try putting in $cprof[wildheal] or focusedheal
and i get no result when i remove the one line and try [5]

:(


remove the code for cprofs that you have and use this

Code
$temp = explode(";",$data->cprof);
foreach ((array) $temp as $value) {
$temp2 = explode(",",$value);
$cprof[(int)$temp2[0]] = (int)$temp2[1];
}


now use it with $cprof[5]
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jun 5 2009 08:55am
Code
$cprof = array(
                     ice => 0,      // set names and fill them with 0's  so we always get a result from a call
                    fire => 0,      
               lightning => 0,      
                    wind => 0,      
                   earth => 0,      
                wildheal => 0,      
                    heal => 0,      
             focusedheal => 0 );    



$c = split(";",$data->cprof);
     foreach ($c as $a)
     {
   $cpn = array( 0 => 'ice', 1 => 'fire', 2 => 'lightning', 3 => 'wind', 4 => 'earth', 5 => 'wildheal', 6 => 'heal', 7 => 'focusedheal');  
   $temp = split(",",$a);
   $cpname =  $temp[0];
   $cpdata =  $temp[1];
   $cpname = $cpn[(int)$cpname];
   $cprof[$cpname] = $cpdata;
}

$temp = explode(";",$data->cprof);
foreach ((array) $temp as $value) {
$temp2 = explode(",",$value);
$cprof[(int)$temp2[0]] = (int)$temp2[1];
}


ImageTTFText ($image, 13, 0, 160, 29, $white, $font4, $cprof[5]);


no result

removed: $cpname = $cpn[(int)$cpname]; aswell, no result

This post was edited by coldguy on Jun 5 2009 08:59am
Member
Posts: 9,133
Joined: Apr 14 2009
Gold: Locked
Trader: Scammer
Warn: 10%
Jun 6 2009 10:26am
Hey guys, I have a problem, maybe someone could help me? :mellow: Willing to don8 if anyone helps me resolve this :)

Anyways,
What I'm basically trying to do is upload the top portion of this signature, and add LS stats to it.


The problem is, the quality gets absolutely destroyed when I'm uploading it. It comes out looking like this:


Do I need to add in extra code to fix the quality issue, or what? :O

The text, functions, etc. work properly, but the quality just gets absolutely destroyed for some reason. Here's my code if someone wouldn't mind taking a look at it (Lots commented out, because it's pointless atm).
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 = 25;

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

// set some colours for future use
$cool  = imagecolorallocate($image, 81, 86, 96);
$lightgreen = imagecolorallocate($image, 200, 206, 171);
$red   = imagecolorallocate($image, 255, 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 = '/Desig.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=281795');
$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, $cool);
//imagefilledrectangle($image, 180, 59, $brpixelX, 71, $red);


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

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

// EXP bar text
//ImageTTFText ($image, 9, 0, 10, 40, $lightgreen, $font, "To Level: ");
//ImageTTFText ($image, 9, 0, 10, 50, $yellow, $font, $percent."%");

//show name
//ImageTTFText ($image, 9, 0, 122, 33, $yellow, $font, "HC Name: ");
//ImageTTFText ($image, 9, 0, 180, 33, $red, $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: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jun 6 2009 11:34am
do you want to make the background transparent or something?
Member
Posts: 9,133
Joined: Apr 14 2009
Gold: Locked
Trader: Scammer
Warn: 10%
Jun 6 2009 12:02pm
Quote (coldguy @ Sat, Jun 6 2009, 01:34pm)
do you want to make the background transparent or something?


Yeah, basically. The top of the signature is on a transparent background and I want it to remain like that.
If you look at what's uploaded right now on the server, it turns into a garbled mess of square boxes for some reason. :wacko:
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jun 6 2009 12:32pm
you can't use a transparent background in a dynamic signature.

use JSP background code to make the background the same color as jsp background
Member
Posts: 4,620
Joined: Aug 3 2008
Gold: 525.25
Jun 6 2009 06:02pm
Quote (coldguy @ Sat, Jun 6 2009, 02:32pm)
you can't use a transparent background in a dynamic signature.

use JSP background code to make the background the same color as jsp background


I understand your trying to help but your giving out false information.

i'll pm you the added code for transparency


This post was edited by SilentXer0 on Jun 6 2009 06:03pm
Go Back To Ladder Slasher Topic List
Prev1414243444560Next
Add Reply New Topic New Poll