SA-MP Forums Archive
Problem with Player count packet data. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with Player count packet data. (/showthread.php?tid=280803)



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' >> 0xFF);
    
$packet .= "i";
    
fwrite($fp$packet);
    
$junk fread($fp11);
    
$password ord(fread($fp1));
    
$players ord(fread($fp2));
    
$maxplayers ord(fread($fp,2));
    
$strlen ord(fread($fp4));
    
$hostname fread($fp,$strlen);
    
$strlen ord(fread($fp4));
    
$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($im255255255);
$gray imagecolorallocate($im200200200);
$darkblueish imagecolorallocate($im120120200);
$blueish imagecolorallocate($im200200255);
$font 'visitor2.ttf';
$largesize 12;
$midsize 10;
$smallsize 9;
imagettftext($im$midsize0159$white$font$hostname);
imagettftext($im$smallsize025512$darkblueish$font"Players");
imagettftext($im$largesize030012$blueish$font$fraction);
imagettftext($im$smallsize01517$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
View Post
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.