Cstrike-Zone
Doriti să reactionati la acest mesaj? Creati un cont în câteva clickuri sau conectati-vă pentru a continua.

Cstrike-Zone


 
AcasaPortalGalerieCăutareUltimele imaginiÎnregistrareConectare

 

 Clasa info servere hlds

In jos 
AutorMesaj
zNh
..::LeGeNd of GoDz::..
..::LeGeNd of GoDz::..
zNh


Numarul mesajelor : 171
Varsta : 34
Localisation : JaPaN/YoKoHaMa
Data de inscriere : 10/05/2007

Clasa info servere hlds Empty
MesajSubiect: Clasa info servere hlds   Clasa info servere hlds Icon_minitimeMier Iun 06, 2007 11:04 pm

Clasa info servere hlds

Code:

<class>port = $portin; } else { $this->port = "27015"; }
$this->ip = $ipin;
$this->command = "\377\377\377\377infostring\0";
// infostring can be replaced with players too, but it returns some strange things.. so...
}
function connect() {

if($this->ip != NULL) {
// Open a connection to the server
$this->fp = fsockopen("udp://".$this->ip, $this->port, $errno, $errstr);

//Send the request to the server.
fwrite($this->fp, $this->command);

//Remove the junk headers sent back
$JunkHead = fread($this->fp,24);

// Check to see if the server is running
$CheckStatus = socket_get_status($this->fp);
if($CheckStatus["unread_bytes"] == 0){
$this->err = "Unable to connect to the server, ensure the IP and port is correct and that the server is running."; $this->errno = 2;
}
} else { $this->err = "There hasn't been entered any IP"; $this->errno = 1; }
}
function process() {
if(!$errno) {
// Read through the returned data and put in variable
$do = 1;
$HLServerStats= "";
while($do) {
$str = fread($this->fp,1);
$HLServerStats.= $str;
$status = socket_get_status($this->fp);
if($status["unread_bytes"] == 0) {$do = 0;}
}
//Close the connection
fclose($this->fp);

// Explode the packet into an array.
$HLServerStats = explode("\\", $HLServerStats);

// Count the amount of keys in the array.
$count = count($HLServerStats);

// The amount of keys in the array MUST be an even number
if($count % 2 == 0)
{
// Loop though all the keys and put them in the $ServerData array with the key values.
$i = 0;
while($count != $i)
{
$ServerData[$HLServerStats[$i]] = $HLServerStats[$i+1];
$i = $i + 2;
}
$this->data=$ServerData;
}
}
}
}
/*

--------------------------------------------------------------------------------
Returned Values
--------------------------------------------------------------------------------
Returned data from the code will return some commonly used information about the server. Here is a list of keys you can use use and a description of what they are:
address - IP Address of the server
players - Number of players currently playing
max - Max number of players that can connect
gamedir - Directory of the mod being played (IE: tfc)
map - Current map being played
type - Type of server: d for dedicated, l for listen.
os - OS the server is running on: w for Windows, l for Linux.

Now, if you're going to use the data in a webpage, the data is all stored in the data array which is contained in the object. You can now use the following code snippet, simply changing "VALUENAME" to the key of the value you wish to display. simply use
*/
$server = new server("86.55.132.198", "27015");
$asd=$server->connect();
$server->process();
if(!$server->errno) {
echo $server->data['map'];
} else {
echo "An error no. ".$server->errno." has been encountered: ".$server->err;
}
?>

Pentru a o utiliza trebuie sa aveti socketurile activate din PHP.ini.
Sus In jos
https://cstrike-zone.all-up.com
 
Clasa info servere hlds
Sus 
Pagina 1 din 1
 Subiecte similare
-
» CrazyCLUB.info
» cs.fragers.info
» RS.rulscs.info
» Cs.Kzone.info
» Cs.CsExplozivE.Info

Permisiunile acestui forum:Nu puteti raspunde la subiectele acestui forum
Cstrike-Zone :: ..::TuToRiAlE::.. :: ...::Tutoriale Php & Html & PhpBB2::...-
Mergi direct la: