• 0

Liste des joueurs connectés


magicyan

Question

12 réponses à cette question

Messages recommandés

Posté(e)

c'est du php

voici server.php

[cpp]

<?php

function SecuriseEntree($chaineorigine)

{

$retour = stripslashes($chaineorigine);

$retour = preg_replace("[\||\r|\t|#]", '', $retour);

$retour = str_replace(';', ',', $retour);

$retour = htmlentities($retour);

$retour = nl2br($retour);

return $retour;

}

$ip = "jeux2.vossey.com";

$port = "27016";

if ( $ip != "" )

if ( $port != "" )

require_once("hlserver.inc.php");

$adresse=$ip.":".$port;

$gameinfo = new HLserver($adresse);

$info = $gameinfo->serverInfo();

if ( ( ! $gameinfo->ping() ) || ( ! is_array ( $info ) ) )

{

}

else

{

$screen = "./images/" . $info['map'] . "" ;

$screen = ereg_replace("$",".jpg",$screen);

print '

';

//images map

if (is_file("$screen") )

{

$mapimage = $screen;

echo" \"".$info['map']."\"\n";

}

else

{

echo" \"".$info['map']."\"\n";

}

print '

';

//compte joeur

$connect=$info['players'];

$maxplayers=$info['maxplayers'];

//cherche mod

$mod_num = 0;

if ( $info['mod_dir'] == "cstrike" )

$mod_num = 10;

if ( $info['mod_dir'] == "tfc" )

$mod_num = 20;

if ( $info['mod_dir'] == "dod" )

$mod_num = 30;

if ( $info['mod_dir'] == "dmc" )

$mod_num = 40;

if ( $info['mod_dir'] == "czero" )

$mod_num = 50;

//affichage dans un tableau

print 'MOD : ';

print " ".$info['description']."\n";

print '

';

print 'IP : ';

print "".$adresse."\n";

print '

';

print 'joeurs : ';

print " ".$connect."/".$maxplayers."\n";

print '

';

print 'map en cour : ';

print " ".$info['map']."\n";

print '

';

}

?>[/cpp]

et hlserver.inc.php

[cpp]<?php

class HLserver {

var $_ip;

var $_port;

var $_socket;

var $_timeout;

var $_data;

var $_info;

var $_ruleList;

var $_playerList;

var $_protocol;

var $_mod;

var $_secure;

function HLserver($serverAddress) {

$exploded = explode(":", $serverAddress, 3);

$this->_ip = $exploded[0];

$this->_port = $exploded[1];

$this->_timeout = 10;

}

function connectServer()

{

if (!$this->_socket = @fsockopen('udp://' . $this->_ip, $this->_port, $errno, $errstr, $this->_timeout)) return false;

return true;

}

function closeServer()

{

if (!@fclose($this->_socket)) return false;

return true;

}

function _writeData($command)

{

// Messages are sent to the server by sending 4 consecutive bytes of 255 (32-bit integer -1)

// and then the string command followed by a zero byte to terminate it

if (!fwrite($this->_socket, "\xFF\xFF\xFF\xFF" . $command . "\x00")) return false;

return true;

}

function _readData()

{

socket_set_timeout($this->_socket, $this->_timeout);

$data = fread($this->_socket, 1);

switch (ord($data)) {

case 255: // Just one datagram

$status = socket_get_status($this->_socket);

socket_set_timeout($this->_socket, $this->_timeout);

$data .= fread($this->_socket, $status['unread_bytes']);

break;

case 254: // More than one datagram

$status = socket_get_status($this->_socket);

socket_set_timeout($this->_socket, $this->_timeout);

fread($this->_socket, 7);

socket_set_timeout($this->_socket, $this->_timeout);

$data = fread($this->_socket, 1);

$bits = sprintf('%08b',ord($data));

$count = bindec(substr($bits, -4));

$x = bindec(substr($bits, 0, 4));

$status = socket_get_status($this->_socket);

socket_set_timeout($this->_socket, $this->_timeout);

$datagrams[$x] = fread($this->_socket, $status['unread_bytes']);

for ($i=1; $i<$count; $i++) {

socket_set_timeout($this->_socket, $this->_timeout);

fread($this->_socket, 8);

socket_set_timeout($this->_socket, $this->_timeout);

$data = fread($this->_socket, 1);

$x = bindec(substr(sprintf('%08b',ord($data)), 0, 4));

$status = socket_get_status($this->_socket);

socket_set_timeout($this->_socket, $this->_timeout);

$datagrams[$x] = fread($this->_socket, $status['unread_bytes']);

}

$data = '';

for ($i=0; $i<$count; $i++) {

$data .= $datagrams[$i];

}

break;

}

$this->_data = $data;

return true;

}

function _getByte()

{

$data = substr($this->_data, 0, 1);

$this->_data = substr($this->_data, 1);

return ord($data);

}

function _getInt16()

{

$data = substr($this->_data, 0, 2);

$this->_data = substr($this->_data, 2);

$array = @unpack('Sshort', $data);

return $array['short'];

}

function _getInt32()

{

$data = substr($this->_data, 0, 4);

$this->_data = substr($this->_data, 4);

$array = @unpack('Lint', $data);

return $array['int'];

}

function _getFloat32()

{

$data = substr($this->_data, 0, 4);

$this->_data = substr($this->_data, 4);

$array = @unpack('ffloat', $data);

return $array['float'];

}

function _getString()

{

$data = '';

$byte = substr($this->_data, 0, 1);

$this->_data = substr($this->_data, 1);

while (ord($byte) != '0') {

$data .= $byte;

$byte = substr($this->_data, 0, 1);

$this->_data = substr($this->_data, 1);

}

return $data;

}

function ping()

{

// There is no 'ping' command, but we can request

// server info and check if its up, and also if

// it's HL2 or HL1 (if its HL1, show it as offline)

if (!$this->connectServer()) return false;

if (!$this->_writeData('TSource Engine Query')) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('m')) return false;

if (!$this->closeServer()) return false;

return true;

}

function serverInfo()

{

$info = array();

if (!$this->connectServer()) return false;

if (!$this->_writeData('TSource Engine Query')) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('m')) return false;

$info['address'] = $this->_getString();

$info['hostname'] = $this->_getString();

$info['map'] = $this->_getString();

$info['mod_dir'] = $this->_getString();

$info['description'] = $this->_getString();

$info['players'] = $this->_getByte();

$info['maxplayers'] = $this->_getByte();

$info['protocol'] = $this->_getByte();

$server_type = $this->_getByte();

switch ($server_type) {

case ord('l'):

$info['server_type'] = "Listen";

break;

case ord('d'):

$info['server_type'] = "Dedicated";

break;

}

$server_os = $this->_getByte();

switch ($server_os) {

case ord('w'):

$info['os'] = 'Windows';

break;

case ord('l'):

$info['os'] = 'Linux';

break;

}

$password = $this->_getByte();

switch ($password) {

case 1:

$info['password'] = "Actif";

break;

default:

$info['password'] = "Inactif";

break;

}

$info['mod_enabled'] = $this->_getByte();

if ($info['mod_enabled'] == 1) {

$info['mod_url'] = $this->_getString();

$info['mod_download'] = $this->_getString();

$this->_getString();

$info['mod_ver'] = $this->_getInt32();

$info['mod_size'] = $this->_getInt32();

$info['mod_serverside'] = $this->_getByte();

$info['mod_customdll'] = $this->_getByte();

}

$secure = $this->_getByte();

$info['secure'] = $secure ? "Oui" : "Non";

$info['numbots'] = $this->_getByte();

if (!$this->closeServer()) return false;

$this->_protocol = $info['protocol'];

$this->_mod = $info['description'];

$this->_secure = $secure;

$this->_info = $info;

return $info;

}

function playerList()

{

$players = array();

if (!$this->connectServer()) return false;

if (!$this->_writeData('W')) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('A')) return false;

$challenge = pack('C*', $this->_getByte(), $this->_getByte(), $this->_getByte(), $this->_getByte());

if (!$this->_writeData('U' . $challenge)) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('D')) return false;

$count = $this->_getByte();

for ($i=0; $i<$count; $i++) {

$players['id'][$i] = $this->_getByte();

$players['name'][$i] = $this->_getString();

$players['frags'][$i] = $this->_getInt32();

$time = $this->_getFloat32();

$minutes = floor($time / 60);

$seconds = floor($time - ($minutes * 60));

$players['time'][$i] = sprintf('%02s min %02s sec', $minutes, $seconds);

}

$this->_playerList = $players;

if (!$this->closeServer()) return false;

return $players;

}

function ruleList()

{

$rules = array();

if (!$this->connectServer()) return false;

//

if (!$this->_writeData('W')) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('A')) return false;

$challenge = pack('C*', $this->_getByte(), $this->_getByte(), $this->_getByte(), $this->_getByte());

if (!$this->_writeData('V' . $challenge)) return false;

if (!$this->_readData()) return false;

$this->_getInt32();

if ($this->_getByte() != ord('E')) return false;

//

$count = $this->_getInt16();

for ($i=0; $i<$count; $i++) {

$rule = $this->_getString();

$value = $this->_getString();

$rules[$rule] = $value;

}

$this->_ruleList = $rules;

if (!$this->closeServer()) return false;

return $rules;

}

function getMod() {

return $this->_mod;

}

// Utilise encore Won ?

function use_won() {

if ( $this->_protocol == 46 ) {

return true;

}

return false;

}

// Utilise Steam ?

function use_steam() {

if ( $this->_protocol == 47 ) {

return true;

}

return false;

}

// VAC activé ?

function is_vac_secure() {

if ( $this->_secure == "1" )

return true;

return false;

}

// Retourne la liste des cvars

function get_cvars() {

$this->_rules = $this->ruleList();

return $this->_rules;

}

// Retourne la valeur de la cvar $string ( avec la taile $size à préciser )

function get_cvar($string,$size) {

$_copyrules = $this->_rules;

if ( is_array ( $_copyrules ) ) {

while (list($key, $value) = each($_copyrules)) {

if ( strncmp ( $key , $string , $size ) == 0 )

return $value;

}

}

return "";

}

// Version du Metamod ?

function get_metamod_vers () {

return ( $this->get_cvar("metamod_version",15) );

}

// Version AMX

function get_amx_vers () {

return ( $this->get_cvar("amx_version",11) );

}

// Version AMXModX

function get_amxx_vers () {

return ( $this->get_cvar("amxmodx_version",15) );

}

// Version AdminMod

function get_adminmod_vers () {

return ( $this->get_cvar("admin_mod_version",17) );

}

// Version Statsme

function get_statsme_vers () {

return ( $this->get_cvar("statsme_version",15) );

}

// Version ClanMod

function get_clanmod_vers () {

return ( $this->get_cvar("clanmod_version",15) );

}

// Version AMX Match Deluxe

function get_amxmatchdeluxe_vers () {

return ( $this->get_cvar("amx_match_deluxe",16) );

}

// Version HL Guard

function get_hlguard_vers () {

if ( $this->get_cvar("hlg_version",11) == "" )

return ( $this->get_cvar("hlguard_version",11) );

else

return ( $this->get_cvar("hlg_version",15) );

}

// Version Cheating death

function get_cd_vers () {

return ( $this->get_cvar("cdversion",9) );

}

// Valeur du CD Required

function get_cd_required () {

return ( $this->get_cvar("cdrequired",10) );

}

// Version Black CD Mediator

function get_blackcd_vers () {

return ( $this->get_cvar("BlackCD_VERSION",15) );

}

// Version ATAC

function get_atac_vers () {

return ( $this->get_cvar("atac_version",12) );

}

// Version AXN

function get_axn_vers () {

return ( $this->get_cvar("axn_version",11) );

}

// Version BMX

function get_bmx_vers () {

return ( $this->get_cvar("bmx_version",11) );

}

// Version BallTrap

function get_balltrap_vers () {

return ( $this->get_cvar("balltrap_version",16) );

}

// Metamod présent ? ( pour les versions inférieures à MM 1.17 )

function has_metamod () {

if ( $this->get_cvar("metamod_version",15) == "" )

if ( $this->get_cvar("amx_version",11) == "" )

if ( $this->get_cvar("admin_mod_version",17) == "" )

if ( $this->get_cvar("statsme_version",15) == "" )

if ( $this->get_cvar("clanmod_version",15) == "" )

if ( $this->get_cvar("hlguard_version",15) == "" )

if ( $this->get_cvar("cdversion",9) == "" )

if ( $this->get_cvar("amxmodx_version",15) == "" )

return 0;

return 1;

}

// Version SH

function get_mod_superhero () {

return ( $this->get_cvar("SuperHeroMod_Version",20) );

}

// Version War3

function get_mod_war3 () {

return ( $this->get_cvar("Warcraft_3",10) );

}

// Version War3 2 ( FT et autres ... )

function get_mod_war3_2 () {

return ( $this->get_cvar("War3",4) );

}

// Version ChickenMod

function get_mod_chicken () {

return ( $this->get_cvar("chickenmod_version",18) );

}

// Version ChickenMod ( vieilles versions )

function get_mod_chicken_2 () {

return ( $this->get_cvar("chicken_version",15) );

}

// Version PredatorMod

function get_mod_predator () {

return ( $this->get_cvar("predator_version",18) );

}

// Version Webmod

function get_mod_webmod () {

return ( $this->get_cvar("w_version",9) );

}

// Version SoccerMod

function get_mod_soccer () {

return ( $this->get_cvar("soccer_version",14) );

}

// Version Jail Break

function get_mod_jail_break () {

return ( $this->get_cvar("Jail_Break",10) );

}

// Version Jaba TV

function get_mod_jaba_tv () {

return ( $this->get_cvar("jabatv_version",14) );

}

};

?>[/cpp]

et pour joindre le serveur

server.php?ip=jeux2.vossey.com&port=27016

c'est une modification d'un script connus,je dois verifier si on voit encore les joeurs 8-) car sa fait longtemps

EDIT :: je vais refaire le code pour les joeurs lool car on les voit plus :-s

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.