Runescape Bits & Bytes
https://www.rsbandb.com/forums/

Automatically updating rs hiscore stat thing (tutorial)
https://www.rsbandb.com/forums/viewtopic.php?f=38&t=29232
Page 1 of 1

Author:  Alucardbsm [ April 6th, 2006, 11:14 am ]
Post subject:  Automatically updating rs hiscore stat thing (tutorial)

I wasn't sure if this would go into the guides section or here, but I put it here because there didn't seem to be anything except rs guides there.

Table Of Contents


To quickly find what you're looking for, press Ctrl + F and put in the number.

1.0.0 - Introduction
1.1.0 - Requirements
2.0.0 - Features
3.0.0 - Step-by-step
3.1.0 - mysql database setup
3.2.0 - .htaccess
3.3.0 - Fonts and others
3.4.0 - script.php
3.5.0 - other files

Introduction - 1.0.0


Ok, I made another script before, but there was a request for a runescape lookup. I decided to make a professional level of a script, and I think it works pretty good. My server went down to a hard drive failure, so this is being written alot later than I hoped.

This is basically the other script I wrote with a ton more features. I decided to save bandwidth over hard drive space (who wouldn't?), so if you end up getting alot of members, be sure to have enough space (+ bandwidth).

This is for ADVANCED people that know how this stuff works. If you're not advanced, you can probably still do it, with varied amount of success. I'll tell you what to touch and what not to touch, if you don't know what's going on. There will be several steps involved in getting this to work, and you'll have to experiment around alot so try not to get frustrated (I was probably more frustrated writing this than you having to make it work :wink:). If you can't get it to work no matter what, just email me, my email is in the header of the code, or I'll just tell you here, alucardbsm@gmail.com.

Requirements - 1.1.0


Ok, there are a few things you must have in order for this to work for you. I'll put them in a list and explain them:

1. Your own server
2. That server must have PHP and MySQL installed
3. PHP must have GD installed
4. Your server must have a domain name on it

I think that's it. I'll explain below:

1. You must have a server. Not much to explain, but if you don't have one, you'll either have to rent one from a company, or set up your own. I'm not sure how to do your own, and your ISP might get a little mad if you get too much traffic. I personally rent my server, even though they serverly limit you on what you can do. I rent from http://www.site5.com

2. If you don't know if you have PHP installed, you can check with the person you're renting the server from, or you can make a file with this in it and direct your browser to it:
Code:
<?php
phpinfo()
?>

If it comes up with a big page with a ton of info, you have PHP installed. To figure out if you have MySQL or not is a bit different. If you don't know, there's not much I can tell you other than if you PHP, you probably have MySQL.

3. Ok, if you have PHP installed, make the file (like in #2) and execute it.
Code:
<?php
phpinfo()
?>

Scroll down and look for a section with GD in it. If it says installed, you're good. If it says uninstalled or it isn't there, you're sol.

4. Ok, this is little difficult to explain. You have a server, you have PHP, MySQL, and GD installed, but you don't know how to get to it right? Well, you need a domain name (mine is http://www.rsbsc.com). You can buy them from Yahoo! really cheap. Or you can search around and go with mydaddy.com. All I can say is search on google for domain names and go with the best one. You'll have to set that up.

If you don't have anyone of those 4, then this won't work for you. Give up now. If you want to do this and not spend money, good luck. I don't know of any company that gives out free PHP, MySQL, and GD support in their free webhosting. None. If you want to get something like this, expect to pay anywhere from $70 per year (at least for me) for the server and a few bucks a year for the domain. Your average RS player don't have their own server.

Features - 2.0.0


Ok, what the following code will do is listed here:

1. Gets the information from Runescape's hiscore list
2. Takes an original image (that you make) and puts the hiscore information on it
3. When the picture's requested, there are a few things that happen:
* Checks to see if it's been at least a day since last requested
* If yes: It writes a new picture and stores it in specified area, It also gives the new picture to them.
* If no: It gets the stored picture and gives it to them

* Checks to see if User has been created in your database and checks to see if their in the hiscores. Displays message accordingly

So, to put it in the most basic form, it's a runescape hiscore picture that updates once a day (sort of like rsbandb.com's sigs, but this code has nothing to do with whatever they did :wink:). This is useful for clans (probably large ones or ones with members that have alot of cash).

This is 100% changable, meaning if you want to add something, or take something out, you can do it. You'll just need to know PHP.

Step-by-step - 3.0.0


This section will tell you step-by-step on how to get this up and running. We'll start here.

The very first thing you should do is create a folder in your public_html or www folder where you will store information. This will also be where people will go to get their sig, so make it something easy to remember and small. Here's what I used:

dynimg

It would come out http://www.rsbsc.com/dynimg You can put what ever you want, just make it easy.

MySQL database set up - 3.1.0


In the way that I've done this, when they request the picture, it accesses(sp?) your MySQL database and look for 2 things: the username and date of that last time updated. In order to do this, I want you make make a few things:

Make a database called: Whatever you called your folder in the first step, for me, dynimg. My server automatically adds alucardb_ in front of the database name, so mine is called alucardb_dynimg.
Make a table in that database called: info
In the table info, make the following:

field: username | type: varchar(12) | null: No
field: date | type: varchar(10) | null: No
field: hits | type: varchar(6) | null: No | Default: 0

That's it for the database. This is where you'll store your member's usernames, the date their picture was last updated, and the # of times that image has been called (useful to see members with lots of hits and those with very little).

.htaccess - 3.2.0


This file is the main life of this. It won't work right without it. What this file will do is that when someone wants to access their image (let's call it sig.png), it will redirect them to the script that we will be making later. Very useful (I found this loophole myself, I'm sure it's known, but I havn't read anything on it)

Make a regular file in notepad and make this (you will need to edit a bit of it):
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ http://www.rsbsc.com/dynimg/script.php [R,L]

What you need to change is the part that says: "http://www.rsbsc.com/dynimg/script.php" to "http://www.yourdomainname/whateveryoucalledthis/script.php". You havn't made the script.php yet, but make this first anyways.

Little note, you may be wondering why it has http://www.mydomain.com in there. Well to tell the truth, I don't know much about .htaccess and got this off of another site and made some minor adjustments. They had mydomain.com (meaning they wanted to change it to mydomain, but if you keep it as is, it works fine). This basically says (to my knowledge) that anyone that requests anything with an extension of .jpg, .png, or .gif, who didn't come from http://www.mydomain.com, gets redirected to the script we are about to write.

Fonts and others - 3.3.0


Now is the time to get your fonts and other stuff, which I'll explain here. Take your favorate fonts (or download some from http://www.1001fonts.com) and upload them to your server using FTP (http://www.coreftp.com). The text file must end in .TTF

You have to make a picture also. This is the picture that we'll be putting the hiscore stats on. Make it with whatever you have (photoshop, gimp, paint - Let's hope not -, or anything you have that works) and call it sig.png. Upload the picture via FTP to your server.

That's pretty much it for this part.

script.php - 3.4.0


Phew - Finally here. If you thought getting all that other stuff set up was hard work, you're in for a surprise. This is ALOT of work. You will spend most of you time in this script. I will post the entire script, and then break it down and explain it.

Code:
<?php
/*****************************************************************
**                                                **
**     Author: Alucardbsm (Bryan M.)                     **
**     Contact: Alucardbsm@gmail.com                     **
**     Creation Time: First created April 7th, 2006            **
**      Version: 1.0.0                                 **
**     Information:                                    **
**         As requested, I wrote this code because someone      **
**      (name with-held) wanted a code that could call up the   **
**      information from Runescape's high-score page and write  **
**      that information onto an image. This code does that,   **
**      but in conjunction with the .htaccess file included,   **
**      updates any image called at minimum of one day.         **
**                                                **
**       Version Info:                                 **
**         1.0.0:  Initial release. ~Alucardbsm            **
**      Legal Stuff:                                 **
**         I admit that this isn't copyrighted, but as a      **
**      request I would like it if you would keep this header.   **
**      At least that would give me some credit for writing      **
**      this ^.^ THANK YOU VERY MUCH - Have fun               **
*****************************************************************/

header("Content-type: image/png");
$usernameCalled = $_GET['username'];
$usernameCalled = ereg_replace(" ", "_", $usernameCalled);

//connect to database

$host = "localhost";
$user = "username";
$pass = "password";
$connection = mysql_connect($host, $user, $pass);
$db = mysql_select_db("alucardb_dynimg", $connection)
  or die ("ERROR: cannot select database alucardb_dynimg");
$query1 = "SELECT username FROM info WHERE username='$usernameCalled'";
$result1 = mysql_query($query1);
$row = mysql_fetch_array($result1);

if ($row[0] == $usernameCalled)
{

   $today = date("m-d-Y");
   $query2 = mysql_query("SELECT date FROM info WHERE username='$usernameCalled'");
   $result2 = mysql_fetch_array($query2);
   if ($today != $result2[0])
   {

      $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "http://hiscore-web.runescape.com/lang/en/aff/runescape/compare.ws?user1=".$usernameCalled);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_VERBOSE, 0);
        curl_setopt($curl, CURLOPT_HEADER,0);   
        $stats =  curl_exec($curl);
        curl_close($curl);

      $stats = strip_tags($stats);
      $stats = ereg_replace("," , "", $stats);
      $stats = str_replace("," , "", $stats);
      $stats = str_replace("Not&nbsp;Ranked", "1 1 -", $stats);
      $stats = explode(" ", $stats);

      $overallLvl = $stats[798];
      $attackLvl = $stats[807];
      $defenceLvl = $stats[812];
      $strengthLvl = $stats[817];
      $hitpointLvl = $stats[822];
      $rangeLvl = $stats[827];
      $prayerLvl = $stats[832];
      $magicLvl = $stats[837];
      $cookingLvl = $stats[842];
      $woodcuttingLvl = $stats[847];
      $fletchingLvl = $stats[852];
      $fishingLvl = $stats[857];
      $firemakingLvl = $stats[862];
      $craftingLvl = $stats[867];
      $smithingLvl = $stats[872];
      $miningLvl = $stats[877];
      $herbloreLvl = $stats[882];
      $agilityLvl = $stats[887];
      $thievingLvl = $stats[892];
      $slayerLvl = $stats[897];
      $farmingLvl = $stats[902];
      $runecraftingLvl = $stats[907];
      ereg("SkillRankLevelXP Overall (.*) does not feature in the hiscores.", $stats, $error);
      
      $querydate = "UPDATE info SET date='$today' WHERE username='$usernameCalled'";
      mysql_query($querydate);


      if (eregi($usernameCalled, $error[0]))
      {

         $img_handle = imageCreateFromPNG("sig.png");
         
         //INSERT FONTS BELOW
         
         $nameFont = "FT3TO.TFF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
         
         ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, "Error, username not in hiscores");
         
         ImagePng($img_handle, $usernameCalled."png");
         ImageDestroy($img_handle);
      }
      else
      {

         $img_handle = imageCreateFromPNG("sig.png");
         
         //INSERT FONTS BELOW


         $nameFont = "FT3TO.TTF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
         
         $usernameCalled = ereg_replace("_", " ", $usernameCalled);
         
         ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, $usernameCalled);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $overallLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $attackLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $defenceLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $strengthLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $hitpointLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $rangeLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $prayerLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $magicLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $cookingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $woodcuttingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $fletchingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $fishingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $firemakingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $craftingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $smithingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $miningLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $herbloreLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $agilityLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $thievingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $slayerLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $farmingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $runecraftingLvl);
         
         $usernameCalled = ereg_replace(" ", "_", $usernameCalled);
         
         ImagePng($img_handle, $usernameCalled.".png");
         ImageDestroy($img_handle);
$img_handle = imageCreateFromPNG($usernameCalled.".png");
ImagePNG($img_handle);
ImageDestroy($img_handle);

      }
   }
   else
   {
      $img_handle = imageCreateFromPNG($usernameCalled.".png");



      ImagePng($img_handle);
      ImageDestroy($img_handle);
   }
}
else
{

   $img_handle = imageCreateFromPNG("sig.png");

//INSERT FONTS BELOW


         $nameFont = "FT3TO.TTF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
   
   ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, "Message saying user not created. Visit www.website.com");
   
   ImagePng($img_handle);
   ImageDestroy($img_handle);
}
?>


Ok, bit by bit. I request you keep the header if you're going to use this code. Basically gives my info. You will need to change this part a bit:

Code:
header("Content-type: image/png");
$usernameCalled = $_GET['username'];
$usernameCalled = ereg_replace(" ", "_", $usernameCalled);

//connect to database

$host = "localhost";
$user = "username";
$pass = "password";
$connection = mysql_connect($host, $user, $pass);
$db = mysql_select_db("alucardb_dynimg", $connection)
  or die ("ERROR: cannot select database alucardb_dynimg");
$query1 = "SELECT username FROM info WHERE username='$usernameCalled'";
$result1 = mysql_query($query1);
$row = mysql_fetch_array($result1);


Change:

$user = "Change this to your username to connect to mysql";
$pass = "the password - duh";
$db = mysql_select_db("Change it to your database name, in this example, alucardb_dynimg", $connection)
or die ("ERROR: cannot select database yourdatabasename");

That's all you need to change, the other stuff you shouldn't touch unless you know what you're doing.

Code:
if ($row[0] == $usernameCalled)
{

   $today = date("m-d-Y");
   $query2 = mysql_query("SELECT date FROM info WHERE username='$usernameCalled'");
   $result2 = mysql_fetch_array($query2);
   if ($today != $result2[0])
   {

      $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "http://hiscore-web.runescape.com/lang/en/aff/runescape/compare.ws?user1=".$usernameCalled);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_VERBOSE, 0);
        curl_setopt($curl, CURLOPT_HEADER,0);   
        $stats =  curl_exec($curl);
        curl_close($curl);

      $stats = strip_tags($stats);
      $stats = ereg_replace("," , "", $stats);
      $stats = str_replace("," , "", $stats);
      $stats = str_replace("Not&nbsp;Ranked", "1 1 -", $stats);
      $stats = explode(" ", $stats);

      $overallLvl = $stats[798];
      $attackLvl = $stats[807];
      $defenceLvl = $stats[812];
      $strengthLvl = $stats[817];
      $hitpointLvl = $stats[822];
      $rangeLvl = $stats[827];
      $prayerLvl = $stats[832];
      $magicLvl = $stats[837];
      $cookingLvl = $stats[842];
      $woodcuttingLvl = $stats[847];
      $fletchingLvl = $stats[852];
      $fishingLvl = $stats[857];
      $firemakingLvl = $stats[862];
      $craftingLvl = $stats[867];
      $smithingLvl = $stats[872];
      $miningLvl = $stats[877];
      $herbloreLvl = $stats[882];
      $agilityLvl = $stats[887];
      $thievingLvl = $stats[892];
      $slayerLvl = $stats[897];
      $farmingLvl = $stats[902];
      $runecraftingLvl = $stats[907];
      ereg("SkillRankLevelXP Overall (.*) does not feature in the hiscores.", $stats, $error);
     
      $querydate = "UPDATE info SET date='$today' WHERE username='$usernameCalled'";
      mysql_query($querydate);


There is no need to touch any of this. Don't unless you know what you're doing, or you'll mess it up.

Code:
if (eregi($usernameCalled, $error[0]))
      {

         $img_handle = imageCreateFromPNG("sig.png");
         
         //INSERT FONTS BELOW
         
         $nameFont = "FT3TO.TFF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
         
         ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, "Error, username not in hiscores");
         
         ImagePng($img_handle, $usernameCalled."png");
         ImageDestroy($img_handle);
      }


Change:

$img_handle = imageCreateFromPNG("what ever your image is, in our expample, sig.png");

//INSERT FONTS BELOW

$nameFont = "yourfont.ttf";
$nameFont2 = "extrafont.ttf";

//INSERT FONTS ABOVE
//INSERT FONT COLORS BELOW

$fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
$fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
$fontColorWhatever = ImageColorAllocate ($img_handle, #, #, #);

//INSERT FONT COLORS ABOVE

ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, "Error, username not in hiscores");

Ok, this last one is going to take a little explaining because you're going to be changing it ALOT. Keep the part that says "ImageTTFText ($img_handle," but change the fontsize to the size of the font you want (make it a # with no quotes). Fontangle change to a # also, but I suggest keeping it 0. x-posistion is the # of pixels to the right from the left side of the image. y-posistion is the # of pixels to the bottom from the top of the image. You can change the $fontColorBlack to the color that you want (you have to of added it eariler with the ImageColorAllocate). You can also change the $nameFont to the font you want to show. The last part in quotes is what will be written on the image. For this part, I suggest changing it to something that lets people know that NONE of their stats are in the hiscores.

You will be changing this and testing it quite a bit to get it perfect, so you'll have to have some patience.

Code:
else
      {

         $img_handle = imageCreateFromPNG("sig.png");
         
         //INSERT FONTS BELOW


         $nameFont = "FT3TO.TTF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
         
         $usernameCalled = ereg_replace("_", " ", $usernameCalled);
         
         ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, $usernameCalled);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $overallLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $attackLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $defenceLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $strengthLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $hitpointLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $rangeLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $prayerLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $magicLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $cookingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $woodcuttingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $fletchingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $fishingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $firemakingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $craftingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $smithingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $miningLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $herbloreLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $agilityLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $thievingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $slayerLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $farmingLvl);
         ImageTTFText ($img_handle, fontsize, fontangle, x-posistion, y-posistion, $fontColorBlack, $nameFont, $runecraftingLvl);
         
         $usernameCalled = ereg_replace(" ", "_", $usernameCalled);
         
         ImagePng($img_handle, $usernameCalled.".png");
         ImageDestroy($img_handle);
$img_handle = imageCreateFromPNG($usernameCalled.".png");
ImagePNG($img_handle);
ImageDestroy($img_handle);

      }


This is the main part (where it updates all the information from the hiscores). Change the fonts, the colors, and imageTTFText. All of them also :wink:. Nothing other than that is needed.

Code:
}
   else
   {
      $img_handle = imageCreateFromPNG($usernameCalled.".png");



      ImagePng($img_handle);
      ImageDestroy($img_handle);
   }
}


This part is where it calls a picture if it doesn't need to be updated. No change is required here.

Code:
else
{

   $img_handle = imageCreateFromPNG("sig.png");

//INSERT FONTS BELOW


         $nameFont = "FT3TO.TTF";
         
         //INSERT FONTS ABOVE
         //INSERT FONT COLORS BELOW
         
         $fontColorBlack = ImageColorAllocate ($img_handle, 0, 0, 0);
         $fontColorWhite = ImageColorAllocate ($img_handle, 225, 225, 225);
         
         //INSERT FONT COLORS ABOVE
   
   ImageTTFText ($img_handle, 23, 0, 20, 20, $fontColorBlack, $nameFont, "Message saying user not created. Visit www.website.com");
   
   ImagePng($img_handle);
   ImageDestroy($img_handle);
}
?>


This part is where it can't find the username in the database so it creates an image that says "can't find it, visit my website NOW" (or whatever you want). Change the font, the colors, and the imagettftext. It then closes and phew, done.

Chances are that even if you wrote this and did everything, it won't work right. You'll need to tinker around with everything yourself (that's why this is an ADVANCED guide) to get it right. This is because every image is unique in where the text needs to go.

This code + guide isn't perfect. Do what works.

Now that everything's done with, in order to get this all set up, you'll need to make a website that let's people create a user accounts (inputs username and date into your mysql database). You then show them the URL of the image. In order for them to see it, what you do is:

Code:
http://www.yourdomain.com/whateveryoucalledthis/sig.png?username=zezima


My brain has officially turned off after writing all of this and you'll have to bear with this rough version of a guide. I think that's it, oh yeah, the hits counter is missing (forgot that), but I'll add it later. I need to rest my brain.

Have fun with the code (if you can get it to work).

Author:  Adbot [ April 6th, 2006, 11:14 am ]
Post subject:  Register and login to get these in-post ads to disappear


Author:  CreepyPirate [ April 6th, 2006, 11:20 am ]
Post subject: 

Hmm tihnk you made the right choice putting it here.

Don't know if Mike and Shane plan on putting these type of guides up on there site and that's what the guides area is reall y supposed to be used for. ;)

Interesting guide.

Author:  Leandero [ April 6th, 2006, 12:09 pm ]
Post subject: 

well prepared guide (confusing for people without an overly high IQ like me, but nice anyway).

on another note, wouldnt it be nice to have a "guides" link on the homepage?

then make a seperate page for them, delete the guides forum (after a 2 week notice or any other period of time) and take the best guides and post them there?

Author:  CreepyPirate [ April 6th, 2006, 12:18 pm ]
Post subject: 

Leandero wrote:
well prepared guide (confusing for people without an overly high IQ like me, but nice anyway).

on another note, wouldnt it be nice to have a "guides" link on the homepage?

then make a seperate page for them, delete the guides forum (after a 2 week notice or any other period of time) and take the best guides and post them there?


We sorta already do that, best guides will be put up on the site although we wont delete the others or link to them.

Author:  Leandero [ April 6th, 2006, 12:25 pm ]
Post subject: 

creepybacon wrote:
Leandero wrote:
well prepared guide (confusing for people without an overly high IQ like me, but nice anyway).

on another note, wouldnt it be nice to have a "guides" link on the homepage?

then make a seperate page for them, delete the guides forum (after a 2 week notice or any other period of time) and take the best guides and post them there?


We sorta already do that, best guides will be put up on the site although we wont delete the others or link to them.


here comes my punch sentence:

but how efficient is it :P

any new people checking out RSBandB won't directly go to the forums to check out the guides simply because they don't know they are there. If you add an "easy to notice" link on the frontpage it might attract a few more people...

just my opinion :)

Author:  CreepyPirate [ April 6th, 2006, 12:29 pm ]
Post subject: 

Leandero wrote:
creepybacon wrote:
Leandero wrote:
well prepared guide (confusing for people without an overly high IQ like me, but nice anyway).

on another note, wouldnt it be nice to have a "guides" link on the homepage?

then make a seperate page for them, delete the guides forum (after a 2 week notice or any other period of time) and take the best guides and post them there?


We sorta already do that, best guides will be put up on the site although we wont delete the others or link to them.


here comes my punch sentence:

but how efficient is it :P

any new people checking out RSBandB won't directly go to the forums to check out the guides simply because they don't know they are there. If you add an "easy to notice" link on the frontpage it might attract a few more people...

just my opinion :)


Well last reply in here - because this is offtopic rather majorly but it doesn't sound like a bad idea. If you'd like to suggest it in the rsbandb area i can see it happening. You'd have my support.

Author:  Adbot [ April 6th, 2006, 12:29 pm ]
Post subject:  Register and login to get these in-post ads to disappear


Author:  jrdgames [ April 6th, 2006, 4:48 pm ]
Post subject: 

Good guide, although this doesnt quite show how to make dynamic runescape signatures it does show how to make a dynamic count-down image/signature.

You may want to add something like this to your code so you don't have to worry about people using your source and not giving credit, of corse they can remove it but thats baaad.
Code:
//###################################################
//#Copyright © 2006 Alucardbsm(or your real name)   #
//#Email: your_email@yourprovider.com               #
//#This Copyright must stay intact for              #
//#legal use of this code.                          #
//###################################################

Author:  Alucardbsm [ April 6th, 2006, 6:20 pm ]
Post subject: 

Yeah, this is just a code I sat down and wrote last night, so I didn't add all that extra stuff. If anybody wants me to write some code for a Runescape dyanmic sig, I will make it. (I made one once, so the one I'd write now would be better)

Author:  jrdgames [ April 7th, 2006, 1:27 pm ]
Post subject: 

Alucardbsm wrote:
If anybody wants me to write some code for a Runescape dyanmic sig, I will make it. (I made one once, so the one I'd write now would be better)

If you wouldn't mind writing it then I would like to use it.

Author:  Alucardbsm [ April 7th, 2006, 2:08 pm ]
Post subject: 

jrdgames wrote:
If you wouldn't mind writing it then I would like to use it.


Ok, give me some time to write it ^^

EDIT: Ok, done, my brain is mush now though

Author:  jrdgames [ April 10th, 2006, 4:15 pm ]
Post subject: 

thank you very much ill try this out later.

Author:  Jeff [ April 10th, 2006, 5:10 pm ]
Post subject: 

How long did it take for you to get the characters right?
There is a more effiecent way than counting characters and exploding.

Author:  Alucardbsm [ April 10th, 2006, 9:07 pm ]
Post subject: 

Jeff wrote:
How long did it take for you to get the characters right?
There is a more effiecent way than counting characters and exploding.


I know there is, but I use this way because I made it before so it only took a few minutes to get it right. Plus, the amount of time for it to do that is so insignificant I didn't want to write a new way. ^^

EDIT: I don't think I counted characters.. What I did is explode it with by spaces and put it into an array and then just call a certain area of the array out. Dunno how inefficient that is (I can think of less effcient ways at least)

Author:  Nate [ April 11th, 2006, 5:02 am ]
Post subject: 

Yeah you did a good job there. Way to much time put into it, but a very good job indeed. :)

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/