PDA

View Full Version : PHP / Counter-strike question


Dennis
06-03-03, 05:55 PM
I was wondering how you would go about putting a server ip and port and making php print out your ping to the server, how many players are in the server, list player names / frags / time played, and list the server rules.


How would i go about doing this?


any help would be apreciated


Thanks,
-Dennis

Dave
07-19-03, 05:18 AM
Isn't there a script that does this? I am pretty sure I have seen a script that will put your Counter-Strike server statistics online...

acidHL
11-21-03, 05:03 AM
This won't do all of what you ask but it's a start:


// Host / Port Settings:
$host = "192.168.254.254";
$port = "27010";

function getstr($sock_hnd)
{
$data = " ";
while (ord($char = fgetc($sock_hnd)))
{
$data .= $char;
}
return $data;

}

$sock_hnd = fsockopen("udp://$host", $port, $errno, $errstr);
fwrite($sock_hnd, "˙˙˙˙info");

if (fread($sock_hnd, 5) == '˙˙˙˙C')
{
$server[ip] = getstr($sock_hnd); // Server IP
$server[hostname] = getstr($sock_hnd); // Server Host
$server[map] = getstr($sock_hnd); // Server Map
$server[mod] = getstr($sock_hnd); // Server Mod
$server[desc] = getstr($sock_hnd); // Server desc
$sinfo = unpack("cactive/cmax/cver", fread($sock_hnd, 3));
$server[users] = $sinfo['active'] . "/" . $sinfo['max']; // Server users
}
fclose($sock_hnd);



And use the variables defined as needed :)

alienzero
12-22-03, 07:47 PM
This script is awsome! I wonder if you would be so kind as to futher it's glory and have it show the players names, connect times and frags?
Thank you very much! :p:

jaredweb
12-30-03, 07:53 AM
Hi there,

There's a very robust script package called Psycho Stats, It has everything you need.

http://www.psychostats.com/downloads.php

Cheers

nacarls
01-04-04, 05:46 PM
This script is just a rcon class for a large majority of servers.

In order to call information you do the following in your code:


<?php

// Include the class
include("rcon.inc.php");

// Designate the server(s) type ('hl', 'q3', 'bf1942', 'jk2' etc etc) and IP and PORT
$servers['halflife'] = array('hl', '192.168.0.1', '27015');
$servers['halflife'] = array('hl', '192.168.0.1', '27016');

// Create the class
$query = = new GameQ;
$data = $query->GetInfo($servers);

// go through all servers
foreach ($servers AS $server_id => $values) {

// if there are no error messages, print out the data for the server
if (!isset($query->errmsg[$server_id])) {
echo '<strong>Data from "'.$server_id.'"</strong><pre>';
print_r($data[$server_id]);
echo '</pre><br><br>';
}
// if there are error messages, print them
else {
echo '<strong>something went wrong while querying "'.$server_id.'":</strong><br>'.$query->errmsg[$server_id].'<br><br>';
}
}

?>


See if this works for you

alienzero
01-15-04, 02:02 PM
Fatal error: Call to undefined function: stream_set_timeout() in /var/www/html/rcon.inc.php on line 111

nacarls
01-15-04, 07:49 PM
you probably have an older version of php. This script is known to work with php 4.3 and higher. You might want to upgrade or ask your webhosting provider to update.

http://www.php.net/stream_set_timeout

You might be able to use the old function instead.

I have attached an edited version of rcon.in.php that hopefully works on older php installs.

alienzero
01-16-04, 10:59 AM
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/rcon_includes/inc.hl.php on line 5

alienzero
01-19-04, 07:12 AM
NVM. Just go here: http://www.czaries.net/scripts/ and grab CzarQuery. Works perfectly.