Problem with Player count packet data. -
hakre1 - 03.09.2011
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:
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);
?>
Re: Problem with Player count packet data. -
hakre1 - 03.09.2011
Also wanted to note that it seems to be working fine with some other servers I grabbed from the server list.
Our server is running 2.2.556 if that helps.
an example of what it outputs:
it says max players = 243 when it really is 499
What further confuses me is that the server list shows the correct information.
Re: Problem with Player count packet data. -
[MWR]Blood - 03.09.2011
This is not a PHP support forum.
Re: Problem with Player count packet data. -
hakre1 - 03.09.2011
Quote:
Originally Posted by [MWR]Blood
This is not a PHP support forum.
|
What kind of a stupid statement is that?
While my code is in PHP the problem is with the packet data being recieved from the SA-MP server.
I provided the code simply for reference, not because I believe their is a problem with it.
Not to mention there are plenty of other examples of similar php scripts on this forum.