d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1464748495060Next
Add Reply New Topic New Poll
Member
Posts: 5,435
Joined: Feb 22 2009
Gold: 0.00
Jul 3 2009 09:50pm
Quote (stiffleronfire @ Fri, Jul 3 2009, 11:39pm)
bump.


bump ;)
Member
Posts: 5,053
Joined: Jul 3 2006
Gold: 198.86
Jul 4 2009 10:55am
*cough*

I spent about 2 hours trying to figure out how to make proficiencies show....need help please. :(
Member
Posts: 12,867
Joined: Mar 10 2004
Gold: 573.84
Jul 5 2009 02:29am
Quote (stiffleronfire @ Sat, Jul 4 2009, 05:55pm)
*cough*

I spent about 2 hours trying to figure out how to make proficiencies show....need help please. :(


pm me what help you need
Member
Posts: 15,364
Joined: May 11 2003
Gold: 11,084.90
Jul 6 2009 02:10am
Ok.. so i decided to attempt getting caster proficiencies working..
It seems that most of the values are correct.

I am curious on why my Ice Prof is wrong?
I am assuming wild heal has no value because i do not have any points into the prof.


Character Reference
http://forums.d2jsp.org/user.php?c=3&i=30409&p=105404

Current Prof Values
Ice - 22
Fire - 7
Lightning - 10
Wind - 2
Earth - 1
Wheal - 0 (0.00)
Heal - 0 (0.10)
Fheal - 7




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                         *
******************************************************/
// create the image from a background jpg
$image = imagecreatefrompng('bg.png');

// set some colours for future use
$cool  = imagecolorallocate($image, 81, 86, 96);
$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 = '/avqest.ttf';

/******************************************************
*                     LOAD DATA                      *
******************************************************/
// 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=105404');
$cprof = array(
                     ice => 0,      
                    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];
$cprof[$cpname] = $cpdata;

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

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

//Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color,

font, "text");

ImageTTFText ($image, 9, 0, 122, 33, $yellow, $font, "Ice: ");
ImageTTFText ($image, 9, 0, 160, 33, $red, $font, $cprof[0]);

ImageTTFText ($image, 9, 0, 200, 33, $yellow, $font, "Fire: ");
ImageTTFText ($image, 9, 0, 240, 33, $red, $font, $cprof[1]);

ImageTTFText ($image, 9, 0, 122, 45, $yellow, $font, "Lightning: ");
ImageTTFText ($image, 9, 0, 180, 45, $red, $font, $cprof[2]);

ImageTTFText ($image, 9, 0, 200, 45, $yellow, $font, "Wind: ");
ImageTTFText ($image, 9, 0, 240, 45, $red, $font, $cprof[3]);

ImageTTFText ($image, 9, 0, 122, 57, $yellow, $font, "Earth: ");
ImageTTFText ($image, 9, 0, 160, 57, $red, $font, $cprof[4]);

ImageTTFText ($image, 9, 0, 200, 57, $yellow, $font, "W-Heal: ");
ImageTTFText ($image, 9, 0, 240, 57, $red, $font, $cprof[5]);

ImageTTFText ($image, 9, 0, 122, 69, $yellow, $font,"Heal:");
ImageTTFText ($image, 9, 0, 160, 69, $red, $font, $cprof[6]);

ImageTTFText ($image, 9, 0, 200, 69, $yellow, $font,"F-Heal:");
ImageTTFText ($image, 9, 0, 250, 69, $red, $font, $cprof[7]);

// output and destroy
imagepng($image);
imagedestroy($image);

?>


RESULT

Member
Posts: 8,547
Joined: Jun 1 2008
Gold: 0.00
Jul 7 2009 10:42am
Hey,
I am having some severe problems trying to make it work...
I've tried on several servers and on all that support php5 I just get an invalid image (blank icon with red "X") icon
I've tried other method for making the script an image: naming a folder "image.png" and naming the script index.php5 within that folder, but though I fixed a 500 Internal Server Error issue thi way on one of the servers, that fails as well to make the thing work
I need some help here... :unsure:

here's my 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 = 100;
$expbar_height = 25;

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

// set some colours for future use
$cool  = imagecolorallocate($image, 81, 86, 96);
$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 = 'DarkAges.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=287962');
$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, 122, 69, $yellow, $font, "To Level: ");
ImageTTFText ($image, 9, 0, 220, 69, $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);

// Show useless shizzle
ImageTTFText ($image, 9, 0, 122, 82, $yellow, $font, "-------------------------------------");
ImageTTFText ($image, 9, 0, 122, 95, $red, $font, "GoT-Guild LadderSlasher Player | Bring ce GPs!");

// 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;
}

?>


this is my 'godless.png.php5' file, which I uploaded along with '.htaccess' file, 'bg.png' image and 'DarkAges.ttf' font file
with the folder method there is no '.htaccess' file and the php file is named 'index.php'

http://godless.hostei.com/godless.png example of .htaccess method
http://godless.za.pl/godless.png example of fixed '500 Internal Server Error' with folder method

help pls
Member
Posts: 8,547
Joined: Jun 1 2008
Gold: 0.00
Jul 7 2009 01:57pm
okey I finally got it to work:D


nvm got it

This post was edited by Godless_hc on Jul 7 2009 02:22pm
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Jul 8 2009 12:20pm
here, this is a function what reads the char xml with the proficiencies too

Code
function readxml($charid) {

$xml = 'http://ladderslasher.d2jsp.org/xmlChar.php?i='.$charid;
$test = file($xml);
if(count($test)>1) $data = simplexml_load_file($xml);
else return false;

$carr = array('None', 'Fighter', 'Barbarian', 'Rogue', 'Magician', 'Guardian', 'Samurai', 'Paladin', 'Monk', 'Ninja', 'Warlock', 'Headhunter', 'Alchemist');
$pwarr = array('sword'  => 0,
   'club'  => 0,
   'axe'  => 0,
   'dagger' => 0,
   'staff'  => 0,
   'longsword' => 0,
   'warhammer' => 0,
   'battleaxe' => 0,
   'spear'  => 0,
   'polearm' => 0
 );
$pcarr = array('ice'  => 0,
   'fire'  => 0,
   'light'  => 0,
   'wind'  => 0,
   'earth'  => 0,
   'wild'  => 0,
   'heal'  => 0,
   'focused' => 0,
 );
$psarr = array('fish'  => 0,
   'cook'  => 0,
   'glyph'  => 0,
   'mute'  => 0,
 );
$charr = array();

$exp = $data->exp;
$exp = (int)$exp;
$cid = $data->classid;
$cid = (int)$cid;


$pw = $data->wprof;
$pc = $data->cprof;
$ps = $data->sprof;


$w = explode(";", $pw);
$c = explode(";", $pc);
$s = explode(";", $ps);

for($i=0;$i<count($w);$i++) {
$in = explode(",", $w[$i]);
$f=0;
foreach($pwarr as $key => $value) {
 if($in[0]==$f) {
  $pwarr[$key] = (int)$in[1];
 }
 $f++;
}
}

for($i=0;$i<count($c);$i++) {
$in = explode(",", $c[$i]);
$f=0;
foreach($pcarr as $key => $value) {
 if($in[0]==$f) {
  $pcarr[$key] = (int)$in[1];
 }
 $f++;
}
}

for($i=0;$i<count($s);$i++) {
$in = explode(",", $s[$i]);
$f=0;
foreach($psarr as $key => $value) {
 if($in[0]==$f) {
  $psarr[$key] = (int)$in[1];
 }
 $f++;
}
}

$charr['name'] = $data->name;
$charr['core'] = $data->core;
$charr['lvl'] = $data->level;
$charr['kil'] = $data->kills;
$charr['dea'] = $data->deaths;
$charr['lac'] = $data->lastaction;
$charr['str'] = $data->strength;
$charr['dex'] = $data->dexterity;
$charr['vit'] = $data->vitality;
$charr['int'] = $data->intelligence;
$charr['hpm'] = $data->hpmax;
$charr['mpm'] = $data->mpmax;
$charr['mqa'] = $data->mqattempts;
$charr['mqp'] = $data->mqpasses;
$charr['class'] = $carr[$cid];
$charr['exp'] = $exp;
$charr['w']  = $pwarr;
$charr['c']  = $pcarr;
$charr['s']  = $psarr;


return $charr;
}



run the function with the charid

Code
readxml(112562)



the returned array looks like this

Code
/*
Array (
[name] => PerfectExceeder
[core] => 0
[lvl] => 6
[kil] => 146532
[dea] => 3500
[lac] => 1246979854
[str] => 70
[dex] => 44
[vit] => 55
[int] => 20
[hpm] => 385
[mpm] => 140
[mqa] => 18
[mqp] => 2
[class] => Samurai
[exp] => 5002748

[w]  => Array (
 [sword]  => 0
 [club]  => 3
 [axe]  => 0
 [dagger] => 3
 [staff]  => 3
 [longsword] => 0
 [warhammer] => 0
 [battleaxe] => 0
 [spear]  => 0
 [polearm] => 0
 )

[c] => Array (
 [ice]  => 2
 [fire]  => 0
 [light]  => 2
 [wind]  => 3
 [earth]  => 0
 [wild]  => 0
 [heal]  => 1
 [focused] => 2
)

[s] => Array (
 [fish]  => 0
 [cook]  => 0
 [glyph]  => 0
 [mute]  => 0
)
*/



so if you want to know the mute skill

Code
$char = readxml(112562);
echo $char["s"]["mute"];


or the class

Code
$char = readxml(112562);
echo $char["class"];
Member
Posts: 15,364
Joined: May 11 2003
Gold: 11,084.90
Jul 8 2009 01:41pm
Thanks for the code and help dunaicapa. :)
it works nicely.
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Jul 8 2009 02:48pm
Quote (GimmeCoffee @ Wed, 8 Jul 2009, 20:41)
Thanks for the code and help dunaicapa. :)
it works nicely.


np ^^

the % to next prof lvl bar should be looks like this (not tested yet)

Code
$forebg   = imagecolorallocatealpha($image, 50, 50, 50, 50);
$backbg   = imagecolorallocatealpha($image, 50, 50, 50, 50);
$borderbg = imagecolorallocatealpha($image, 50, 50, 50, 50);

$x = 100; // x coord
$y = 100; // y coord
$w = 200; // the max width of the bar
$h = 10;  // height

$expw = $w*$hits/(1000+$proflvl*1000);  // <-- thats the point, the actual percentage of the proficiency

imagerectangle($image, $x-1, $y-1, $x+$w+1, $y+$h+1, $borderbg); // border
imagefilledrectangle($image, $x, $y, $x+$w, $y+$h, $backbg);  // bg
imagefilledrectangle($image, $x, $y, $x+$expw, $y+$h, $forebg);  // <-- draw the % rectangle
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jul 9 2009 01:38am
i'll test it now

ok found problems...
it makes a rectangle but it doesn't load because we don't load any other data.

this is my xml data: <cprof>1,0,1;2,0,6;5,1,581;6,0,140;7,2,1470</cprof>
in the code above i changed the $proflvl to $cprof[7] to load focussed heal. = 2. so now it makes 1000+2*1000 (=3000 (max amount of hits)
also the $hits in the code doesn't do anything yet... so we need a way to split this proficiency: 7,2,1470 (7 meaning focussed heal, 2 meaning prof level, 1470 means amount of hits <-- this is what we need for hits.

we can tell me, and all who want this, how to split this?

This post was edited by coldguy on Jul 9 2009 01:59am
Go Back To Ladder Slasher Topic List
Prev1464748495060Next
Add Reply New Topic New Poll