SRCDS Steam group


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Game Server Banner :D
#1
I was bored and went digging through files, rather than using an image background I just used a solid color, I will further develop upon this and make it better.

Here are some basics:
1. Icons for GameType / Operating System
2. Shows: Players, Name, IP, and Map

To Do:
1. Make a whole bunch of damn flag icons and show server location.
2. Create a banner creator page where you can generate your own banners with different images, and upload your own!
3. Fix hard edges on icons.
4. Add more game icons.
5. Changeable text color and font.

Examples: ( These are real time )
[Image: query.php?ip=96.31.81.190&port=2...lor=555500]
[Image: query.php?ip=204.27.58.210&port=...lor=13404a]
[Image: query.php?ip=208.76.248.35&port=...lor=0055ff]
Looking for a game server? Visit fullfrag.com and pick one up as low as $2.50 / mo!
Reply
#2
Cool any source?
~ trewq
Reply
#3
I'm not the best at PHP, but I know enough...

I'm nazi about my source code because its sloppy, I will share this version only.

PHP Code:
<?php
/* SOURCE ENGINE QUERY FUNCTION, requires the server ip:port */
function source_query($ip){
    
$cut = explode(":", $ip);
    
$HL2_address = $cut[0];
    
$HL2_port = $cut[1];

    
$HL2_command = "\377\377\377\377TSource Engine Query\0";
    
    
$HL2_socket = fsockopen("udp://".$HL2_address, $HL2_port, $errno, $errstr,3);
    
fwrite($HL2_socket, $HL2_command); 
    
$JunkHead = fread($HL2_socket,4);
    
$CheckStatus = socket_get_status($HL2_socket);

    if(
$CheckStatus["unread_bytes"] == 0)return 0;

    
$do = 1;
    while(
$do){
        
$str = fread($HL2_socket,1);
        
$HL2_stats.= $str;
        
$status = socket_get_status($HL2_socket);
        if(
$status["unread_bytes"] == 0){
               
$do = 0;
        }
    }
    
fclose($HL2_socket);

    
$x = 0;
    while (
$x <= strlen($HL2_stats)){
        
$x++;
        
$result.= substr($HL2_stats, $x, 1);    
    }
    
    
// ord ( string $string );
    
$result = str_split($result);
    
$info['network'] = ord($result[0]);$char = 1;
    while(
ord($result[$char]) != "%00"){$info['name'] .= $result[$char];$char++;}$char++;
    while(
ord($result[$char]) != "%00"){$info['map'] .= $result[$char];$char++;}$char++;
    while(
ord($result[$char]) != "%00"){$info['dir'] .= $result[$char];$char++;}$char++;
    while(
ord($result[$char]) != "%00"){$info['description'] .= $result[$char];$char++;}$char++;
    
$info['appid'] = ord($result[$char].$result[($char+1)]);$char += 2;        
    
$info['players'] = ord($result[$char]);$char++;    
    
$info['max'] = ord($result[$char]);$char++;    
    
$info['bots'] = ord($result[$char]);$char++;    
    
$info['dedicated'] = ord($result[$char]);$char++;    
    
$info['os'] = chr(ord($result[$char]));$char++;    
    
$info['password'] = ord($result[$char]);$char++;    
    
$info['secure'] = ord($result[$char]);$char++;    
    while(
ord($result[$char]) != "%00"){$info['version'] .= $result[$char];$char++;}
    
    return 
$info;
}


    
$ip = $_GET['ip'];
    
$port = $_GET['port'];
    
$color = $_GET['color'];
    if(
strlen($color) == 6 )
    {
    
$hex = sscanf($color, '%2x%2x%2x');
    
$r = $hex[0];
    
$g = $hex[1];
    
$b = $hex[2];
    }
    else
    {
    
$hex[0] = 0;
    
$hex[1] = 0;
    
$hex[2] = 0;
    }
    
    
$q = source_query($ip.':'.$port);
    
    
$servername = $q['name'];
    
$servermap = $q['map'];
    
$servermaxplayers = $q['max'];
    
$servertotalplayers = $q['players'];
    
$bg = 'bg3';
    
    if(
$q['os'] == 'w')
    {
    
$os = 'windows';
    }
    else
    {
    
$os = 'linux';
    }
    
    switch (
$q['appid'])
    {
    case 
240:
        
$game = 'css';
        break;
    case 
440:
        
$game = 'tf2';
        break;
    case 
160:
        
$game = 'gmod';
        break;
    default:
        
$game = 'hl2';
        break;
    }
    
    
    
$oslogo = imagecreatefromgif('logo/'.$os.'.gif');
    
$gamelogo = imagecreatefromgif('logo/'.$game.'.gif');
    
    
$image = imagecreatetruecolor(400, 40);
    
$bg = imagecolorallocate($image, $r, $g, $b);
    
imagefilledrectangle($image, 0, 0, 399, 39, $bg);
    
    
    if(
$q['password'] == '1')
    {
    
$locklogo = imagecreatefromgif('logo/lock.gif');
    
imagecopymerge($image, $locklogo, 41, 21, 0, 0, 16, 16, 100);
    
imagedestroy($locklogo);  
    }
    
    
imagecopymerge($image, $oslogo, 4, 21, 0, 0, 16, 16, 100);
    
imagecopymerge($image, $gamelogo, 23, 21, 0, 0, 16, 16, 100);
    
imagedestroy($oslogo);  
    
imagedestroy($gamelogo);
    
    
// Prepare Colours
    //int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
    
$green = imagecolorallocate($image, 0, 255, 0);
    
$white = imagecolorallocate($image, 255, 255, 255);
    
    
// Prepare Font
    
$font = 'font/arial.ttf';
    
$bold = 'font/StencilStd.otf';
    
// Prepare Dimension Variables
    
$height = imagesy($image);
    
$width = imagesx($image);
    
$text_area_height = 0;

    
imagettftext($image, 10, 0, 5, 16, $white, $font, $servertotalplayers.'/'.$servermaxplayers.' - '.$servername);
    
imagettftext($image, 10, 0, 60, 34, $green, $font, 'IP: '.$ip.':'.$port.' Map: '.$servermap);
    
// array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )

    // Send image to browser as PNG
    
header("Content-type: image/png");
    
imagepng($image);
?>

Ignore how I did some things, I know there are simpler ways, This isn't my cleaned up code, I had a bit of debugging to do, so bits and pieces are left.
Looking for a game server? Visit fullfrag.com and pick one up as low as $2.50 / mo!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)