d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1545556575860Next
Add Reply New Topic New Poll
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Oct 8 2009 04:09pm
Quote (keefer7 @ Thu, 8 Oct 2009, 23:07)
i dont get this

how does it work?

like how does it show it/ will it show on a sig?


for example
if your char is 36th on sc longsword ladder, the function returns "36"
Member
Posts: 9,437
Joined: Jan 3 2008
Gold: 2.85
Oct 8 2009 04:32pm
Quote (dunaicapa @ Thu, Oct 8 2009, 06:09pm)
for example
if your char is 36th on sc longsword ladder, the function returns "36"


oh so it wont show on a sig cause that would be pimpin :P
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Oct 9 2009 04:02am
bit upgraded function
Code
function laddernr($charid, $t, $c='sc') {
 $tarr = array(
   'allclasses' => 't=0&c=0', 'fighter' => 't=0&c=1', 'barbarian' => 't=0&c=2', 'rogue' => 't=0&c=3', 'magician' => 't=0&c=4', 'guardian' => 't=0&c=5', 'samurai' => 't=0&c=6', 'paladin' => 't=0&c=7', 'monk' => 't=0&c=8', 'ninja' =>  't=0&c=9', 'warlock' => 't=0&c=10', 'headhunter' => 't=0&c=11', 'alchemist' => 't=0&c=12',
   'sword' => 't=1&c=0', 'club' => 't=1&c=1', 'axe' => 't=1&c=2', 'dagger' => 't=1&c=3', 'staff' => 't=1&c=4', 'longsword' => 't=1&c=5', 'warhammer' => 't=1&c=6', 'battleaxe' => 't=1&c=7', 'spear' => 't=1&c=8', 'polearm' => 't=1&c=9',
   'fishing' => 't=3&c=0', 'cooking' => 't=3&c=1', 'glyphing' => 't=3&c=2', 'transmuting' => 't=3&c=3', 'suffusencing' => 't=3&c=4',
   'ice' => 't=2&c=0', 'fire' => 't=2&c=1', 'lightning' => 't=2&c=2', 'wind' => 't=2&c=3', 'earth' => 't=2&c=4', 'wildheal' => 't=2&c=5', 'heal' => 't=2&c=6', 'focusedheal' => 't=2&c=7');
 $core = ($c=='sc') ? 'h=0&' : 'h=1&';
 if(!isset($tarr[$t])) return 'invalid type parameter';
 $a = file('http://ladderslasher.d2jsp.org/index.php?a=3&'.$core.$tarr[$t]);
 for($i=0;$i<count($a);$i++) if(strpos($a[$i], 'p='.$charid)) $r = trim(strip_tags($a[$i-1]));
 return (isset($r)) ? $r : 'not on ladder';
}



call the function (with the char id and ladders name like 'dagger' or 'glyphing' or 'wildheal' or 'allclasses', optional 3rd variable: 'hc' or 'sc', default is sc)
Code
$myfishladderpos = laddernr(112562, 'fishing');



draw the ladder position
Code
ImageTTFText($image, 9, 0, 65, 30, $white, $font, $myfishladderpos);



example:
Member
Posts: 9,614
Joined: Apr 21 2008
Gold: 7,601.66
Oct 9 2009 04:04am
Quote (dunaicapa @ Fri, 9 Oct 2009, 12:02)
bit upgraded function
Code
function laddernr($charid, $t, $c='sc') {
 $tarr = array(
   'allclasses' => 't=0&c=0', 'fighter' => 't=0&c=1', 'barbarian' => 't=0&c=2', 'rogue' => 't=0&c=3', 'magician' => 't=0&c=4', 'guardian' => 't=0&c=5', 'samurai' => 't=0&c=6', 'paladin' => 't=0&c=7', 'monk' => 't=0&c=8', 'ninja' =>  't=0&c=9', 'warlock' => 't=0&c=10', 'headhunter' => 't=0&c=11', 'alchemist' => 't=0&c=12',
   'sword' => 't=1&c=0', 'club' => 't=1&c=1', 'axe' => 't=1&c=2', 'dagger' => 't=1&c=3', 'staff' => 't=1&c=4', 'longsword' => 't=1&c=5', 'warhammer' => 't=1&c=6', 'battleaxe' => 't=1&c=7', 'spear' => 't=1&c=8', 'polearm' => 't=1&c=9',
   'fishing' => 't=3&c=0', 'cooking' => 't=3&c=1', 'glyphing' => 't=3&c=2', 'transmuting' => 't=3&c=3', 'suffusencing' => 't=3&c=4',
   'ice' => 't=2&c=0', 'fire' => 't=2&c=1', 'lightning' => 't=2&c=2', 'wind' => 't=2&c=3', 'earth' => 't=2&c=4', 'wildheal' => 't=2&c=5', 'heal' => 't=2&c=6', 'focusedheal' => 't=2&c=7');
 $core = ($c=='sc') ? 'h=0&' : 'h=1&';
 if(!isset($tarr[$t])) return 'invalid type parameter';
 $a = file('http://ladderslasher.d2jsp.org/index.php?a=3&'.$core.$tarr[$t]);
 for($i=0;$i<count($a);$i++) if(strpos($a[$i], 'p='.$charid)) $r = trim(strip_tags($a[$i-1]));
 return (isset($r)) ? $r : 'not on ladder';
}



call the function (with the char id and ladders name like 'dagger' or 'glyphing' or 'wildheal' or 'allclasses', optional 3rd variable: 'hc' or 'sc', default is sc)
Code
$myfishladderpos = laddernr(112562, 'fishing');



draw the ladder position
Code
ImageTTFText($image, 9, 0, 65, 30, $white, $font, $myfishladderpos);



example:
http://www.ls.dunaicapa.hu/laddernr.jpg


youre the man dunai, thanks for that!
Member
Posts: 22,448
Joined: Aug 31 2007
Gold: 8,178.38
Oct 14 2009 02:24am
how to make dynamic signature from an animated gif

requirements: php 5 & imagick
check phpinfo(); if you have it

Code
<?php

$charid     = 112562;            // your characters id
$animation  = "./2gv7y91.gif";   // original gif
$fastimage  = "./fastimg.gif";   // cached image (should not change)
$refresh    = 60;                // cache time in seconds
$font       = "./BIRTH_OF_A_HERO.ttf";

if(mktime()-filemtime($fastimage)>$refresh) {

  include('readxml.php');
  $charr  = readxml($charid);
  $strings = array(
//     array(size, rotation, posx, posy, color, font, text),
       array(20, 0, 10, 20, "white", $font, $charr['name'].' '.$charr['lvl'].' '.$charr['class']),
       array(20, 0, 10, 40, "white", $font, 'str '.$charr['str']),
       array(20, 0, 10, 60, "white", $font, $charr['mqa'].' / '.$charr['mqp']),
  );
  $image = new Imagick($animation);
  $draw = new ImagickDraw();
  foreach ($image as $frame) {
     for($i=0;$i<count($strings);$i++) {
        $color = new ImagickPixel($strings[$i][4]);
        $draw->setFillColor($color);
        $draw->setFont($strings[$i][5]);
        $draw->setFontSize($strings[$i][0]);
        $frame->annotateImage($draw, $strings[$i][2], $strings[$i][3], $strings[$i][1], $strings[$i][6]);
     }
  }
  file_put_contents($fastimage, $image->getImagesBlob());
  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');
}
header("Content-type: image/gif");
$image = new Imagick($fastimage);
echo $image->getImagesBlob();
?>


package --> http://www.ls.dunaicapa.hu/anim.gif/anim.gif.rar



This post was edited by dunaicapa on Oct 14 2009 02:25am
Member
Posts: 5,053
Joined: Jul 3 2006
Gold: 198.86
Oct 18 2009 12:47am
Can anyone tell me how to use a .jpg file instead of a .png file? (see my current sig, it is using png-8, and it is a bit grainy. I saved it as a .jpg and it looks way better, same file size too.

I have tried changing:

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

to various things, and it just doesn't work.

Thanks!
Member
Posts: 15,364
Joined: May 11 2003
Gold: 11,084.90
Oct 18 2009 01:05am
Quote (stiffleronfire @ Sun, Oct 18 2009, 02:47am)
Can anyone tell me how to use a .jpg file instead of a .png file? (see my current sig, it is using png-8, and it is a bit grainy. I saved it as a .jpg and it looks way better, same file size too.

I have tried changing:

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

to various things, and it just doesn't work.

Thanks!


$image = imagecreatefromjpeg('imagename.jpg');

This post was edited by GimmeCoffee on Oct 18 2009 01:07am
Member
Posts: 5,053
Joined: Jul 3 2006
Gold: 198.86
Oct 18 2009 07:42am
Ok, I seem to be having an underlying issue. It keeps creating a large size png file, instead of using the jpg file.

These are what I have on the server:





28kb file size jpg:
Code
http://stiffler.hostei.com/sig/as.jpg






I link to the php5 sig file and here is what it turns out as:
98kb file size png:
Code
http://stiffler.hostei.com/sig/stiffler.png






:angry: what am I doing wrong?




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 = imagecreatefromjpeg('as.jpg');

// set some colours for future use
$cool  = imagecolorallocate($image, 81, 86, 96);
$red   = imagecolorallocate($image, 255, 0, 0);
$yellow = imagecolorallocate($image, 255, 181, 53);
$color1 = imagecolorallocate($image, 172, 117, 146);

// 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 = '/NEUROPOL.TTF';
Member
Posts: 9,437
Joined: Jan 3 2008
Gold: 2.85
Oct 18 2009 09:58am
Quote (stiffleronfire @ Sun, Oct 18 2009, 09:42am)
Ok, I seem to be having an underlying issue. It keeps creating a large size png file, instead of using the jpg file.

These are what I have on the server:

http://i158.photobucket.com/albums/t89/Fire_Marshal/sigissue.jpg



28kb file size jpg:
Codehttp://stiffler.hostei.com/sig/as.jpg
http://stiffler.hostei.com/sig/as.jpg




I link to the php5 sig file and here is what it turns out as:
98kb file sizepng:
Codehttp://stiffler.hostei.com/sig/stiffler.png
http://stiffler.hostei.com/sig/stiffler.png




:angry: what am I doing wrong?




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 = imagecreatefromjpeg('as.jpg');

// set some colours for future use
$cool  = imagecolorallocate($image, 81, 86, 96);
$red  = imagecolorallocate($image, 255, 0, 0);
$yellow = imagecolorallocate($image, 255, 181, 53);
$color1 = imagecolorallocate($image, 172, 117, 146);

// 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 = '/NEUROPOL.TTF';


change the directory to sig.jpg

so it would look like this on your ftp


Code
root/public_html/sig.jpg



then change stiffler.png.php5

change to index.php

so the link would now look like this

Code
http://stiffler.hostei.com/sig.jpg



for the code u need to change the image functions

change the three things u see here to what is here
Code
header("Content-type: image/jpg");

$image = ImageCreateFromJPEG("as.jpg");

imagejpeg($image);


This post was edited by keefer7 on Oct 18 2009 10:25am
Member
Posts: 5,053
Joined: Jul 3 2006
Gold: 198.86
Oct 18 2009 10:33am
Thanks keefer7, that works. :)
Go Back To Ladder Slasher Topic List
Prev1545556575860Next
Add Reply New Topic New Poll