Making a Dynamic minecraft status image
Posted: Wed Jun 06, 2012 11:41 pm
i hope someone can help me ,
Alright i got the minecraft status using minequery working and got a image created by php done
only when i try to combine those 2 together the image becomes invalid
here is my code tyring to combine both
Alright i got the minecraft status using minequery working and got a image created by php done
only when i try to combine those 2 together the image becomes invalid
here is my code tyring to combine both
<?php header('Content-Type: image/png'); create_image(); //fetches server information from minequery. function fetch_server_info($ip, $port){ $socket = fsockopen($ip, $port, $errno, $errstr, 2); if ($socket === false){ return false; } fwrite($socket, "QUERY_JSON\n"); $responce = stream_get_contents($socket); return json_decode($responce, true); } $config['server']['ip'] = '66.7.222.221'; $config['server']['port'] = '25566'; $info = fetch_server_info($config['server']['ip'], $config['server']['port']); $test = $info['playerCount']; function create_image(){ $img = imagecreatetruecolor(214, 341); $border = imagecolorallocate($img, 0x1c, 0x1c, 0x1c); $bg = imagecolorallocate($img, 0x42, 0x42, 0x42); imagefill($img, 0, 0, $border); imagefilledrectangle($img, 3, 3, 210, 338, $bg); $font1 = imagecolorallocate($img, 0xff, 0xbf, 0x00); $font2 = imagecolorallocate($img, 0x3a, 0xdf, 0x00); $test1 = '3'; imagettftext($img, 12, 0, 12, 50, $font1, './Fire1.ttf', 'Server IP:'); imagettftext($img, 12, 0, 12, 75, $font2, './Fire1.ttf', $config['server']['ip']); imagettftext($img, 12, 0, 12, 100, $font1, './Fire1.ttf', 'Online Players:'); imagettftext($img, 12, 0, 12, 125, $font2, './Fire1.ttf', $info['playerCount']; \ $info['maxPlayers']); imagettftext($img, 12, 0, 12, 150, $font1, './Fire1.ttf', 'Status:'); imagettftext($img, 12, 0, 12, 175, $font2, './Fire1.ttf', 'ONLINE'); imagettftext($img, 12, 0, 12, 200, $font1, './Fire1.ttf', 'Players:'); imagepng($img); } ?>