Jump to content

[SOLVED] RuneScape Stat Signature Maker


LemonInflux

Recommended Posts

  • Replies 79
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

<?php
$_POST['username'] = 'zezima';
$username = $_POST['username'];
$username = strtolower(str_replace(' ', '_', $username));

$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = array_shift(explode(",", $stats[0]));
$stat['att'] = array_shift(explode(",", $stats[1]));
$stat['def'] = array_shift(explode(",", $stats[2]));
$stat['str'] = array_shift(explode(",", $stats[3]));
$stat['hp'] = array_shift(explode(",", $stats[4]));
$stat['rng'] = array_shift(explode(",", $stats[5]));
$stat['pry'] = array_shift(explode(",", $stats[6]));
$stat['mag'] = array_shift(explode(",", $stats[7]));
$stat['ck'] = array_shift(explode(",", $stats[8]));
$stat['wc'] = array_shift(explode(",", $stats[9]));
$stat['flt'] = array_shift(explode(",", $stats[10]));
$stat['fsh'] = array_shift(explode(",", $stats[11]));
$stat['fm'] = array_shift(explode(",", $stats[12]));
$stat['cra'] = array_shift(explode(",", $stats[13]));
$stat['smi'] = array_shift(explode(",", $stats[14]));
$stat['min'] = array_shift(explode(",", $stats[15]));
$stat['her'] = array_shift(explode(",", $stats[16]));
$stat['ag'] = array_shift(explode(",", $stats[17]));
$stat['th'] = array_shift(explode(",", $stats[18]));
$stat['sl'] = array_shift(explode(",", $stats[19]));
$stat['frm'] = array_shift(explode(",", $stats[20]));
$stat['rc'] = array_shift(explode(",", $stats[21]));
$stat['hun'] = array_shift(explode(",", $stats[22]));
$stat['cs'] = array_shift(explode(",", $stats[23]));


$image_link = 'demo.png';
$image = imagecreatefrompng($image_link);

$font_colour = imagecolorallocate($image, 0, 0, 0);
$font_size = 5; 

$x = array('28', '80', '135', '188', '240'); 
$y = array('8', '29', '52', '77', '100'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagestring($image, $font_size, $x[$a], $y[$i], $value, $font_colour);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagestring($image, $font_size, '240', '82', 'overall: ' . $overall, $font_colour);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

give that a try

Link to comment
Share on other sites

okay, I think the problem is that the image is in the wrong directory.

I just typed in this into the address bar:

http://www.boddingtonparish.co.uk/php/demo.png

and got a 'page cannot be found' error. also the image you've got on the first post is listed at:

http://reflexprojects.net/rs/rs/images/demo.png

on a completely different server.

 

You need to get the url correct for it. Also, not sure if gd can access external images, but don't see why not.

 

change the image link to this:

$image_link = 'http://reflexprojects.net/rs/rs/images/demo.png';

Link to comment
Share on other sites

ah, sorry.. I was thinking you wanted the ranks..

<?php
$username = $_POST['username'];
$username = strtolower(str_replace(' ', '_', $username));

$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = array_shift(explode(",", $stats[0]));
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['flt'] = explode(",", $stats[10]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[13]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['her'] = explode(",", $stats[16]);
$stat['ag'] = explode(",", $stats[17]);
$stat['th'] = explode(",", $stats[18]);
$stat['sl'] = explode(",", $stats[19]);
$stat['frm'] = explode(",", $stats[20]);
$stat['rc'] = explode(",", $stats[21]);
$stat['hun'] = explode(",", $stats[22]);
$stat['cs'] = explode(",", $stats[23]);


$image_link = 'http://reflexprojects.net/rs/rs/images/demo.png';
$image = imagecreatefrompng($image_link);

$font_colour = imagecolorallocate($image, 0, 0, 0);
$font_size = 5; 

$x = array('28', '80', '135', '188', '240'); 
$y = array('8', '29', '52', '77', '100'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagestring($image, $font_size, $x[$a], $y[$i], $value[1], $font_colour);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagestring($image, $font_size, '230', '82', 'overall:' . $overall, $font_colour);
imagestring($image, $font_size, '240', '105', '' . $username, $font_colour);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

Link to comment
Share on other sites

sorry, missed out the total... herre you go:

<?php
$_POST['username'] = 'zezima';
$username = $_POST['username'];
$username = strtolower(str_replace(' ', '_', $username));

$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = explode(",", $stats[0]);
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['flt'] = explode(",", $stats[10]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[13]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['her'] = explode(",", $stats[16]);
$stat['ag'] = explode(",", $stats[17]);
$stat['th'] = explode(",", $stats[18]);
$stat['sl'] = explode(",", $stats[19]);
$stat['frm'] = explode(",", $stats[20]);
$stat['rc'] = explode(",", $stats[21]);
$stat['hun'] = explode(",", $stats[22]);
$stat['cs'] = explode(",", $stats[23]);


$image_link = 'http://reflexprojects.net/rs/rs/images/demo.png';
$image = imagecreatefrompng($image_link);

$font_colour = imagecolorallocate($image, 0, 0, 0);
$font_size = 5; 

$x = array('28', '80', '135', '188', '240'); 
$y = array('8', '29', '52', '77', '100'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagestring($image, $font_size, $x[$a], $y[$i], $value[1], $font_colour);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagestring($image, $font_size, '210', '85', 'overall:' . $overall[1], $font_colour);
imagestring($image, $font_size, '240', '105', '' . $username, $font_colour);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

 

to change the font, you can change it's size by changing the following line:

$font_size = 5;

sizes range from 1 to 5.

 

To change the font itself you should use imagettftext() instead of imagestring(), which is a bit more complicated but allows a lot more variation

 

change to this:

<?php
$_POST['username'] = 'zezima';
$username = $_POST['username'];
$username = strtolower(str_replace(' ', '_', $username));

$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = explode(",", $stats[0]);
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['flt'] = explode(",", $stats[10]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[13]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['her'] = explode(",", $stats[16]);
$stat['ag'] = explode(",", $stats[17]);
$stat['th'] = explode(",", $stats[18]);
$stat['sl'] = explode(",", $stats[19]);
$stat['frm'] = explode(",", $stats[20]);
$stat['rc'] = explode(",", $stats[21]);
$stat['hun'] = explode(",", $stats[22]);
$stat['cs'] = explode(",", $stats[23]);


$image_link = 'http://reflexprojects.net/rs/rs/images/demo.png';
$image = imagecreatefrompng($image_link);

//this is the font. You must include the filetype
$font = 'arial.ttf';
$font_colour = imagecolorallocate($image, 0, 0, 0);
$font_size = 10; 

// x axis
//first number is x position for column 1
//second number is x position for cloumn 2
//third number is x position for column 3
//fourth number is x position for column 4
//fifth number is x position for column 5
$x = array('28', '80', '135', '188', '240');

// y axis
//first number is y position for row 1
//second number is y position for row 2
//third number is y position for row 3
//fourth number is y position for row 4
//fifth number is y position for row 5
$y = array('20', '45', '66', '90', '115'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagettftext($image, $font_size, 0, $x[$a], $y[$i], $font_colour, $font , $value[1]);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagettftext($image, $font_size, 0, '230', '100', $font_colour, $font , 'overall:' . $overall[1]);
imagettftext($image, $font_size, 0, '250', '120', $font_colour, $font , $username);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

note: using this method the font size is now in pixels, so the prevoius maximum of 5 would be very small...

Also you need to upload the font file to the same directory as the others. In this example I'm using arial.ttf, but use whatever you like.

 

You'll have to change the x and y axis for everything depending on the fonts and font sizes too!

I've tried to explain what veach number in the x and y arrays are for.

Link to comment
Share on other sites

you should make it run off the get method, instead of post.

It'd give more flexibility. You should then be able to link it with something like this:

<img src="http://www.boddingtonparish.co.uk/php/processout.php?user=zezima" border="0" alt="runescape stats" />

 

Then people can use it in a web page, instead of just by itself

Link to comment
Share on other sites

I see. How would I do that? Also, the next question was going to be, how would I host it on my server so it updates constantly, instead of people having to get another each time. Kinda like, when you enter your name, the image appears on a page with the url in a box at the bottom. I could work that all out, but how would you do the GET instead of POST?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.