Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Help
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 09.09.2009, 14:23   #1
Michael
Guest
 
Posts: n/a
Default How to L2Who?

i want to know how to made the L2who to put on my webpage how many players are playing on the server... like this page.

http://evermore-world.com/who/index.php?ip=83.222.15.51&port=7777

someone knows?

Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 09-09-2009, 02:23 PM. Открыть источник.
 
Old 09.09.2009, 14:59   #2
FidoW
Guest
 
Posts: n/a
Default How to L2Who?

This example is checking RPGClub Russ server, as you can see... the website online count is like 170% of the real amount.

Website says 2526 online now... the script say 1470... heh!

<?

$gameserverlist = array(

"x1"=>'77.50.0.76',

"x3"=>'77.50.0.77',

"x10"=>'77.50.0.53',

"x30"=>'77.50.0.71',

"x1000"=>'77.50.0.70'

);

foreach($gameserverlist as $name=>$ip) {

$a = getserverdata($ip);

echo "$name ($a[ip]) [$a[protocol] protocol]: current({$a[current]}), playing({$a[playing]}), private store({$a[store]}), max({$a[max]})\n<br>";

$total[current] += $a[current];

$total[playing] += $a[playing];

$total[store] += $a[store];

$total[max] += $a[max];

}

echo "<br>TOTAL: current($total[current]), playing($total[playing]), private store($total[store]) max($total[max])";

function getserverdata($ip="127.0.0.1",$port=7777,$code=14) { // code 0=C1-Interlude // code 14=Kamael-Gracia

$fs=@fsockopen($ip,$port,$errno,$errstr,2);

if (!$fs) return array('protocol'=>0,'status'=>0,'id'=>0,'world'=>0 ,'max'=>0,'current'=>0,'playing'=>0,'store'=>0);

$pck=pack("vCi",6,$code,-3);

fwrite($fs,$pck);

$r=fread($fs,73);

fclose($fs);

if(strlen($r)==0 && $code==14) return getserverdata($ip,$port,0);

$a=@unpack("vsize/Cid/iworld/imax/icurrent/iplaying/istore",$r);

$a['status'] = 1; $a['ip'] = $ip; $a['port'] = $port;

if($code==14) $a['protocol'] = "Kamael";

else $a['protocol'] = "C1-Int";

return $a;

}

?>

Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 09-09-2009, 02:59 PM. Открыть источник.
 
Old 09.09.2009, 15:46   #3
Max
Guest
 
Posts: n/a
Default How to L2Who?

or try whit it <?php

//by Hint (27.06.2008)

class ServerStatus

{

private $ip, $port, $interval, $timeout;

public function __construct($ip = '127.0.0.1', $port = 2106, $interval = 30, $timeout = 1)

{

$this->ip = $ip;

$this->port = $port;

$this->interval = $interval;

$this->timeout = $timeout;

}

public function GetStatusFromAuth()

{

$status = array();

$f = @fsockopen($this->ip, $this->port, $errno, $errstr, $this->timeout);

if ($f)

{

do

{

$sec = floor($this->timeout);

$msec = ($this->timeout - $sec) * 1000;

socket_set_timeout($f, $sec, $msec);

$buf = fread($f, 2);

if (strlen($buf) != 2) break;

$a = unpack('vsize', $buf);

$size = $a['size'] - 2;

if ($size < 1) break;

$buf = fread($f, $size);

if (strlen($buf) != $size) break;

fwrite($f, "\x03\x00\xFE", 3);

$buf = fread($f, 2);

if (strlen($buf) != 2) break;

$a = unpack('vsize', $buf);

$size = $a['size'] - 2;

if ($size < 1) break;

$buf = fread($f, $size);

if (strlen($buf) != $size) break;

if (ord($buf[0]) != 0xFE) break;

if (strlen($buf) < 3) break;

$amount = ord($buf[1]) + ord($buf[2]) * 256;

$buf = substr($buf, 3);

if (strlen($buf) != $amount * 4) break;

$a = unpack('v' . ($amount * 2), $buf);

for ($i = 0; $i < $amount; $i++) $status[$a[$i * 2 + 1]] = $a[$i * 2 + 2];

}

while (false);

fclose ($f);

}

return $status;

}

public function GetStatus()

{

$fn = dirname(__FILE__) . '/status.txt';

$status = array();

fclose(fopen($fn, 'a+b'));

$f = @fopen($fn, 'r+b');

if ($f)

{

flock($f, LOCK_EX);

$cache = unserialize(fread($f, 1024));

$status = @$cache['status'];

$time = @$cache['time'];

if (!IsSet($status) || !IsSet($time))

{

$status = array();

$time = 0;

}

if (time() - $time > $this->interval)

{

$new = $this->GetStatusFromAuth();

foreach ($status as $id => $value)

{

$c = &$status[$id];

$c['on'] = false;

$c['cur'] = 0;

}

foreach ($new as $id => $value)

{

if (!IsSet($status[$id])) $status[$id] = array('on' => false, 'cur' => 0, 'max' => 0);

$c = &$status[$id];

$c['on'] = true;

$c['cur'] = $new[$id];

if ($c['cur'] > $c['max']) $c['max'] = $c['cur'];

}

$cache = array('status' => $status, 'time' => time());

$s = serialize($cache);

rewind($f);

ftruncate($f, 0);

fwrite($f, $s, strlen($s));

}

fclose($f);

}

return $status;

}

public function GetText($id, $online, $offline)

{

$status = $this->GetStatus();

if (IsSet($status[$id])) $c = &$status[$id]; else $c = array('on' => false, 'cur' => 0, 'max' => 0);

$res = str_replace(array('%c', '%m'), array($c['cur'], $c['max']), $c['on'] ? $online : $offline);

return $res;

}

}

$status = new ServerStatus('127.0.0.1');

$online = 'Status: <b><font color="#00AA00">online</font></b> | Players: <b>%c</b> | Record: <b>%m</b>';

$offline = 'Status: <b><font color="#FF0000">offline</font></b> | Players: <b>%c</b> | Record: <b>%m</b>';

echo $status->GetText(1, $online, $offline); //1 - ServerID

?>

Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 09-09-2009, 03:46 PM. Открыть источник.
 
Old 09.09.2009, 16:18   #4
FidoW
Guest
 
Posts: n/a
Default How to L2Who?

Seens you are a script collector monkey.

Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 09-09-2009, 04:18 PM. Открыть источник.
 
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 16:04.