Jump to content

Reading bytes


regdude

Recommended Posts

Hi!

I'm making a server query for Source engine games (like cs).

Made already the main monitor part in php, but now is left some parts that involve bytes in the packets.

http://developer.valvesoftware.com/wiki/Server_Queries#A2S_SERVERQUERY_GETCHALLENGE here are all parts of the packet and what they mean, as far as I figured then everything is sepereted with NUL (\x00). So now I'm stuck with the byte and can't figure out how could I make the byte as a readable number to everyone.

Here is how it should look:

$gotpacket = fread($fp, 4096);
$gotpacket = substr($gotpacket, 5, 4); //removes headers, first chars of the packet is some whacky letters.
$parts = explode("\x00", $gotpacket); //I hope that everything is really sepereted with a \x00!
$maxplayers = $parts[6]; //Not sure if this is right
$maxplayers = somefunction($maxplayers);
echo $maxplayers; // Should be 17

Also this worked fine with connected players, but not with maxplayers:

$playerson = $parts[5];
$playerson = substr($playerson, 0, 1);
$playerson = ord($playerson); //is 15

Link to comment
https://forums.phpfreaks.com/topic/156939-reading-bytes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.