d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1474849505160Next
Add Reply New Topic New Poll
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Jul 9 2009 03:23am
changed it so the associative arrays contains another arrays: the first elements are the proflvl, the other is the hits

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'  => array(0, 0),
    'club'  => array(0, 0),
    'axe'  => array(0, 0),
    'dagger' => array(0, 0),
    'staff'  => array(0, 0),
    'longsword' => array(0, 0),
    'warhammer' => array(0, 0),
    'battleaxe' => array(0, 0),
    'spear'  => array(0, 0),
    'polearm' => array(0, 0)
  );
$pcarr = array('ice'  => array(0, 0),
    'fire'  => array(0, 0),
    'light'  => array(0, 0),
    'wind'  => array(0, 0),
    'earth'  => array(0, 0),
    'wild'  => array(0, 0),
    'heal'  => array(0, 0),
    'focused' => array(0, 0),
  );
$psarr = array('fish'  => array(0, 0),
    'cook'  => array(0, 0),
    'glyph'  => array(0, 0),
    'mute'  => array(0, 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][0] = (int)$in[1];
   $pwarr[$key][1] = (int)$in[2];
  }
  $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][0] = (int)$in[1];
   $pcarr[$key][1] = (int)$in[2];
  }
  $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][0] = (int)$in[1];
   $psarr[$key][1] = (int)$in[2];
  }
  $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;
}


useage:

Code
$char = readxml(112562);
echo $char['s']['mute'][0]; // the skill level
echo $char['s']['mute'][1]; // the hits made
echo $char['class'];  // the class (the same as before)


This post was edited by dunaicapa on Jul 9 2009 03:28am
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jul 9 2009 03:44am
that owns, testing in a min.

thanks ALOT :D
Member
Posts: 45,587
Joined: Jul 26 2005
Gold: 500.00
Jul 9 2009 04:02am
Awesome, Thanks!!!!!!!!
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jul 9 2009 03:53pm
doesn't seem to work for me :(
Member
Posts: 4,797
Joined: Jan 5 2009
Gold: 89.00
Jul 9 2009 06:53pm
Can anyone tell me if php compiles line by line from top to bottom?

Member
Posts: 4,620
Joined: Aug 3 2008
Gold: 525.25
Jul 9 2009 06:59pm
Quote (neffreyl @ Thu, Jul 9 2009, 08:53pm)
Can anyone tell me if php compiles line by line from top to bottom?


top to bottom

define before you use it

This post was edited by SilentXer0 on Jul 9 2009 07:00pm
Member
Posts: 4,797
Joined: Jan 5 2009
Gold: 89.00
Jul 10 2009 12:59am
Quote (SilentXer0 @ Thu, Jul 9 2009, 06:59pm)
top to bottom

define before you use it


Ok so can i have an array get the entire value of another array?

how would i write that? Just $array1 = $array2; ?
Member
Posts: 4,921
Joined: Mar 25 2008
Gold: 1.02
Jul 10 2009 01:40am
Member
Posts: 4,797
Joined: Jan 5 2009
Gold: 89.00
Jul 10 2009 01:50am
Quote (coldguy @ Fri, Jul 10 2009, 01:40am)


I dont need an example. I need to know if all the array values can be initiated into another array in one smooth line. Or does it have to take the whole thing?
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Jul 10 2009 03:45am
proficiency bar




Code
<?php

include('readxml.php');
$char = readxml(112562);

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');

$image = ImageCreateFromPNG('bg.png');

$cr = imagecolorallocatealpha($image, 255, 0, 0, 0);
$cg = imagecolorallocatealpha($image, 0, 255, 0, 0);
$cb = imagecolorallocatealpha($image, 0, 0, 255, 0);
$cw = imagecolorallocatealpha($image, 255, 255, 255, 0);
$cd = imagecolorallocatealpha($image, 0, 0, 0, 0);

$x = 25;
$y = 4;
$w = 120;
$h = 15;

$hits = $char['w']['club'][1];
$plvl = $char['w']['club'][0];
$expw = $w*$hits/(1000+$plvl*1000);
$next = (1000+$plvl*1000);
$asd = $hits/$next*100;

imagerectangle($image, $x-1, $y-1, $x+$w+1, $y+$h+1, $cd);
imagefilledrectangle($image, $x, $y, $x+$w, $y+$h, $cd);
imagefilledrectangle($image, $x, $y, $x+$expw, $y+$h, $cr);

ImageTTFText($image, 12, 0, 66, 17, $cw, '../fonts/sans.ttf', $asd.' %');


imagealphablending($image, true);
imagesavealpha($image, true);

imagepng($image);
imagedestroy($image);

?>


readxml.php contains only the function from this post
Go Back To Ladder Slasher Topic List
Prev1474849505160Next
Add Reply New Topic New Poll