Jump to content
MakeWebGames

User Playercard Online Status


mxyi

Recommended Posts

hey guys i got this code for a player usercard but i wanted to add 'Online :' and after : saying yes or no in them colors how can i add it so it says theyre status? here is the code.. :)

<?php
//Coded By Eternal
//www.deadlyghetto.net
//Leave this please

include "config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_mysql.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
if(isset($_GET['id']) AND ctype_digit($_GET['id'])) {
$id = mysql_real_escape_string(trim($_GET['id']));
}
else {echo" Invalid Action";}
if($id) {


   $query = sprintf("select level, username,money,crystals from users where userid = %u",$id);
   $result = mysql_query($query);

   $data = mysql_fetch_array($result);
$info ="{$data['username']}   \nLevel: {$data['level']} \nCash: \$".number_format($data['money'])."\nCrystals: ".number_format($data['crystals'])."";

// Create a 300x100 image
$im = imagecreatetruecolor(200, 100);
$image = imagecreatefrompng('americawars.png'); // Get a background for jpg it is imagecreatefromjpg()
imagealphablending($image, true); // setting alpha blending on         ~~~ remove if not using png
imagesavealpha($image, true); // save alphablending setting (important)  ~~~ remove if not using png
$color = imagecolorallocate($image, 0x250, 0x250, 0x250);

// Path to our ttf font file
$font_file = 'Babelfish.ttf';


imagefttext($image, 14, 0, 15, 85, $color, $font_file, $info);
//            I     S   R  L   T     C        F          TX
/*************************\
I= Background image
S= Font Size
R= Right Border
L= Left Border
T= Top Border
C Font Color* Colour
F File to load eg.. arial.ttf
TX Text Info
*/
// Output image to the browser
header('Content-Type: image/png');

imagepng($image);
imagedestroy($image);
}
else{echo"
die";}
?>

hope u can help me add the online status because i only know how to add things that are in the mysql database :P thanks!

Link to comment
Share on other sites

It is in the mysql database.

In that code after line 28 add

if($data['laston'] >= time()-15*60) { $on="Online"; } else { $on="Offline"; }

 

Then add to your $info line where you want the status to be displayed.

$info ="{$data['username']} \nLevel: {$data['level']} \nCash: \$".number_format($data['money'])."\nCrystals: ".number_format($data['crystals'])." \nStatus: {$on}";

In order to get it to display in different colours you will need to play with the imagecolorallocate

Link to comment
Share on other sites

  • 2 weeks later...

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.   Paste as plain text instead

  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...