Jump to content

Recommended Posts

Hello, i've just signed up and will probably start coming here a lot.

I've read a bit on the forums and like what I see :)

 

I am curious is to how I could implant the number of players on my game, with an image.

I DO have the script to make an image but what I want is actually more complex than what you are thinking.

 

First examine this image:

 

2r3b0jm.gif

 

Where it says Players, i'd like it to display the amount of players, but with with a font that looks the same way as the players.

 

I can easily create 0, 1, 2, 3... etc up to 9 to have this.

 

I use ADODB which makes coding much easier, so if I were to make this image, i would go along with:

 

$query = $db->execute("select * from players");

$count = $query->recordcount();

 

Then in the file that I already have the script made on, i would probably add something like this:

 

imagestring($image, 3, 115, 15, "$count", white);

 

If it is simply not possbile to add the numbers with the same font as the word "PLAYERS" then that is fine, but the next question would be..

 

How do I make the image I made in php be the background of the banner above?

I've tried a lot and cannot seem to change anything except the background image of the picture.

 

I hope I can be a good part of this community one day, and will start visiting here often.

 

All help on this is MUCH appreciated! Thanks! :)

Link to comment
https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/
Share on other sites

You need to use your .htaccess file and apache mod rewrite to re write requests to the gif file to go to the php file

 

something like...

RewriteEngine On
RewriteBase /
RewriteRule ^image.gif image.php? [QSA]

 

http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Ok here is my code, this will simply show the number of players in the center of a 280 by 50px box, with a transparent background. My goal is to show these players in the banner listed above:

 

<?php
include("lib.php");
$player = check_user($secret_key, $db);


$totplayers = $db->execute("select * from players");

$players = $totplayers->recordcount();



$image = imagecreatetruecolor(280, 50);
$red = imagecolorallocate($image, 255, 0, 0);
$black = imagecolorallocate($image, 0, 0, 0);

// Make the background transparent
imagecolortransparent($image, $black);

$text_color = imagecolorallocate($image, 0, 0, 0);
$white = ImageColorAllocate($image,255,255,255);
$blue = imagecolorallocate($image, 0, 0, 255);
$red = imagecolorallocate($image, 0 , 200, 0);


$bg = imagecolorallocate($image, 255, 255, 255);
$textcolor = imagecolorallocate($image, 1, 1, 1);




imagestring($image, 3, 115, 15, "$players", $textcolor);



header('Content-type: image/png');

imagepng($image);
imagedestroy($image);
?>

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.