03.09.2011, 03:53
I have created a simple script to generate a dynamic userbar using many examples for reference. Everything seems to be working except the player count and max player count are wrong.
They seem to be changing and are at about the same ratio but are nowhere near the actual numbers.
Any idea why the packet data would be wrong?
Here is my code:
They seem to be changing and are at about the same ratio but are nowhere near the actual numbers.
Any idea why the packet data would be wrong?
Here is my code:
PHP Code:
<?php
header('Content-type: image/png');
$content = "test";
$fp = fsockopen("udp://samp.ng-gaming.net", 7777, $errno, $errstr);
if ($fp) {
$packet = 'SAMP';
$packet .= chr('192');
$packet .= chr('168');
$packet .= chr('200');
$packet .= chr('103');
$packet .= chr('7777' & 0xFF);
$packet .= chr('7777' >> 8 & 0xFF);
$packet .= "i";
fwrite($fp, $packet);
$junk = fread($fp, 11);
$password = ord(fread($fp, 1));
$players = ord(fread($fp, 2));
$maxplayers = ord(fread($fp,2));
$strlen = ord(fread($fp, 4));
$hostname = fread($fp,$strlen);
$strlen = ord(fread($fp, 4));
$gamemode = fread($fp,$strlen);
$fraction = htmlentities($players) . "/" . htmlentities($maxplayers);
} else { echo "server not found"; }
fclose($fp);
$shine = imagecreatefrompng("shine.png");
$im = imagecreatefrompng ("userbar.png");
$white = imagecolorallocate($im, 255, 255, 255);
$gray = imagecolorallocate($im, 200, 200, 200);
$darkblueish = imagecolorallocate($im, 120, 120, 200);
$blueish = imagecolorallocate($im, 200, 200, 255);
$font = 'visitor2.ttf';
$largesize = 12;
$midsize = 10;
$smallsize = 9;
imagettftext($im, $midsize, 0, 15, 9, $white, $font, $hostname);
imagettftext($im, $smallsize, 0, 255, 12, $darkblueish, $font, "Players");
imagettftext($im, $largesize, 0, 300, 12, $blueish, $font, $fraction);
imagettftext($im, $smallsize, 0, 15, 17, $gray, $font, $gamemode . " - samp.ng-gaming.net");
imagecopy($im,$shine,360,20,0,0,360,20);
imagepng($im);
imagedestroy($im);
?>