dezkit Posted April 11, 2010 Share Posted April 11, 2010 Hello guys, I am in need of making a packet that I send to a Counter-Strike 1.6 server into an array, here is the reply format: Type byte Should be equal to 'I' (0x49) Version byte Network version. 0x07 is the current Steam version. Goldsource games will return 48 (0x30), also refered to as protocol version. Server Name string The Source server's name, eg: "Recoil NZ CS Server #1" Map string The current map being played, eg: "de_dust" Game Directory string The name of the folder containing the game files, eg: "cstrike" Game Description string A friendly string name for the game type, eg: "Counter Strike: Source" AppID short Steam Application ID Number of players byte The number of players currently on the server Maximum players byte Maximum allowed players for the server Number of bots byte Number of bot players currently on the server Dedicated byte 'l' for listen, 'd' for dedicated, 'p' for SourceTV OS byte Host operating system. 'l' for Linux, 'w' for Windows Password byte If set to 0x01, a password is required to join this server Secure byte if set to 0x01, this server is VAC secured Game Version string The version of the game, eg: "1.0.0.22" Extra Data Flag (EDF) byte if present this specifies which additional data fields will be included if ( EDF & 0x80 ) short The server's game port # is included if ( EDF & 0x10 ) long long The server's SteamID is included if ( EDF & 0x40 ) short string The spectator port # and then the spectator server name are included if ( EDF & 0x20 ) string The game tag data string for the server is included [future use] if ( EDF & 0x01 ) short ?? The Steam Application ID again + several 0x00 bytes Or can be found here. Here is a reply example: ÿÿÿÿI0CAL CS Match Server�cs_italy�cstrike�Counter-Strike� ���dw�1.1.2.6�‡i�¨J0É@ Can anybody bring me on the right foot to this? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198230-trying-to-put-a-packet-into-an-array/ Share on other sites More sharing options...
TeddyKiller Posted April 11, 2010 Share Posted April 11, 2010 You need to state what is the actual problem, and provide some code. Quote Link to comment https://forums.phpfreaks.com/topic/198230-trying-to-put-a-packet-into-an-array/#findComment-1040066 Share on other sites More sharing options...
dezkit Posted April 11, 2010 Author Share Posted April 11, 2010 Problem: I don't know how to put all those fields into an array, because I am not experienced with packets and whatever... Code: <?php class Connect { var $serveraddress; var $portnumber; var $gameserver_status; var $serverdata; function serverStatus($serveraddress, $portnumber){ ini_set(allow_url_fopen,1); $command = "\xFF\xFF\xFF\xFFTSource Engine Query\0\x00"; //var $serv_requestcommand_infos = "\xFF\xFF\xFF\xFFTSource Engine Query\0\x00"; //var $serv_requestcommand_rules = "\xFF\xFF\xFF\xFFV\x00"; //var $serv_requestcommand_players = "\xFF\xFF\xFF\xFFU\x00"; //var $serv_rconcommand1 = "\xFF\xFF\xFF\xFFchallenge rcon\x00"; //var $serv_rconcommand2 = "\xFF\xFF\xFF\xFFrcon"; //var $serv_rconcommand2 = "\xFF\xFF\xFF\xFFrcon"; $waittime = 1.5; $serverdata = ""; if (!$cssocket=fsockopen("udp://".$serveraddress,$portnumber,$errnr)){ $errmsg="No connection"; }else{ socket_set_blocking($cssocket,true); socket_set_timeout($cssocket,0,500000); fwrite($cssocket,$command,strlen($command)); $starttime=time(); do{ $serverdata.=fgetc($cssocket); $serverdatalen++; $socketstatus=socket_get_status($cssocket); if (time() > ($starttime+$waittime)){ $errmsg="Connection timed out"; fclose($cssocket); } } while ($socketstatus["unread_bytes"] ); fclose($cssocket); } $this->serv_infos[0][1] = 'address'; $this->serv_infos[1][1] = 'name'; $this->serv_infos[2][1] = 'map'; $this->serv_infos[3][1] = 'gamename'; $this->serv_infos[4][1] = 'players'; $this->serv_infos[5][1] = 'maxplayers'; $this->serv_infos[6][1] = 'protocol'; $this->serv_infos[0][2] = $ip.":".$port; $this->serv_infos[1][2] = ; $this->serv_infos[2][2] = ; $this->serv_infos[3][2] = ; $this->serv_infos[4][2] = ; $this->serv_infos[5][2] = ; $this->serv_infos[6][2] = ; if (strlen($serverdata) < 5){ $this->gameserver_status = "0"; echo $serverdata; }else{ $this->gameserver_status = "1"; echo $serverdata; } $endtime=time(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/198230-trying-to-put-a-packet-into-an-array/#findComment-1040069 Share on other sites More sharing options...
dezkit Posted April 11, 2010 Author Share Posted April 11, 2010 bumping Quote Link to comment https://forums.phpfreaks.com/topic/198230-trying-to-put-a-packet-into-an-array/#findComment-1040166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.