This is the code i made a long time ago.
http://php.net/manual/en/function.fread.phpPHP Code:
$errno = $errstr = null;
$cmd = "\xFF\xFF\xFF\xFFgetstatus";
$f = fsockopen('udp://' . $ip, $port, $errno, $errstr, $timeout);
if (!$f)
die ("Unable to connect. Error $errno - $errstr\n");
socket_set_timeout ($f, 1, 0);
fwrite ($f, $cmd);
$data = '';
while ($d = fread ($f, 10000)) {
$data .= $d;
}
fclose ($f);
kung foo man (6th May 2015),maxdamage99 (6th May 2015)
LLLLOOOOOOLLLL!!!!!
thx, Mitch :зPHP Code:
$sendpacket = '........'; //dont true
/////
$sendpacket = "......."; //TRUEEE
Mitch (6th May 2015)
Error:
help me!)PHP Code:
Parse error: syntax error, unexpected T_STRING in Z:\xxx\xxx\xxxx\xxxx\xxxxxx.php on line 13
I think that the error in the function explode(); because delimetr "\".PHP Code:
{
$linesinfo = explode("\", $infooservere);
{
echo "Максимальное количество игроков: " . $linesinfo[1];
}
}
" needs to be escaped, hence you need to write "\"", or '"' might work also (with ').
timescale 0.01
maxdamage99 (6th May 2015)
I solved this problem, and now I need to get information on the current number of players on the server ?? What cmd i can do it?
info maxclients: sv_maxclients.
info map: mapname.
info name server: sv_hostname.
info сurrently, the number of players on the server: ?????
If you want to go over a screen session instead of netcat:
Code:(base) homepc@home-pc:~$ screen -S cod2 -p 0 -X hardcopy ~/tmp_screen.txt; tail -n2 ~/tmp_screen.txt Server is not running.
timescale 0.01