[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Функция сбора игроков.
Гость_Алексей
Здравствуйте. мб кто знает в чем проблема.
Функция вывода игроков сервера


<?php


if(!function_exists('getmicrotime')) {
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
}

function cutchar(&$string)
{
$char = substr($string, 0, 1);
$string = substr($string, 1);
return $char;
}
function cutbyte(&$string)
{
$byte = ord(substr($string, 0, 1));
$string = substr($string, 1);
return $byte;
}
function cutstring(&$string)
{
$str = substr($string, 0, StrPos($string, chr(0)));
$string = substr($string, StrPos($string, chr(0))+1);
return $str;
}
function cutshort(&$string)
{
$short = substr($string, 0, 2);
list(,$short) = @unpack("S", $short);
$string = substr($string, 2);
return $short;
}
function cutlong(&$string)
{
$long = substr($string, 0, 4);
list(,$long) = @unpack("l", $long);
$string = substr($string, 4);
return $long;
}
function pastelong($long)
{
return pack("l", $long);
}
function cutfloat(&$string)
{
$float = substr($string, 0, 4);
list(,$float) = @unpack("f", $float);
$string = substr($string, 4);
return $float;
}




function request($request,$server)
{
list($ip,$port) = explode(":", $server);
$request = "\xFF\xFF\xFF\xFF".$request."\x00";
$fp = @fsockopen('udp://'.$ip, $port);
if (!$fp) return false;
@fwrite($fp, $request);
socket_set_timeout($fp, 1);
$string=fread($fp, 10240);
@fclose($fp);
return $string;
}




function players($host,$port) {
$st = request("\x55",$host,$port);
if (!$st) return false;
$st = substr($st, 4);
if (substr($st, 0, 1) == "\x41") {
$otrez = cutlong(substr($st, 1));
$st = request("\x55".pastelong($otrez),$host,$port);
if (!$st) return false;
$st = substr($st, 4);
}
if (substr($st, 0, 1) != "\x44") return false;
$result['Type'] = cutchar($st); // Char: Should be equal to 'D'
$result['Num Players'] = cutbyte($st); // Byte: The number of players reported in response
for ($i = 1; $i <= $result['Num Players']; $i++) {
$result['Index'][$i] = cutbyte($st); // Byte: The index into [0.. Num Players] for this entry
$result['Player Name'][$i] = cutstring($st); // String: Player's name
$result['Kills'][$i] = cutlong($st); // Long: Number of kills this player has
$result['Time connected'][$i] = cutfloat($st); // Float: The time in seconds this player has been connected
}
return $result;
}





print_r(players("91.192.138.95:27015"));

?>






делаем Print выводит


Array ( [Type] => D [Num Players] => 29 [Index] => Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => 0 ) [Player Name] => Array ( [1] => zz_Dif [2] => dmg ! AblM ?! =) [3] => timur97 [4] => n1k3 [5] => lChelios yHociT [6] => 4yd0Vushe [7] => Dissa [8] => Brooklyn [9] => .:Filon:. [10] => [ex_zy] user [11] => zz_top [12] => cTpouTeJIb [13] => ---(--FOX--)--- 102rus [14] => MEOW [15] => NIKE [16] => hspyntik [17] => Mr.moment [18] => ultim@tum [19] => tawu sk`1LL0m [20] => nR0)|()|(0NbIu' # * [21] => Foll > Armik [22] => 3ApAdLo [23] => pro^Team [24] => DOC###### [25] => the killer [26] => METAJlJl! [27] => [S.T.A.R.S]Immort@L [28] => LaN [29] => BorisBritva ) [Kills] => Array ( [1] => 13 [2] => 5 [3] => 5 [4] => 9 [5] => 8 [6] => 15 [7] => 0 [8] => 0 [9] => 1 [10] => 0 [11] => 0 [12] => 4 [13] => 7 [14] => 0 [15] => 0 [16] => 0 [17] => 19 [18] => 0 [19] => 2 [20] => 8 [21] => 18 [22] => 3 [23] => 0 [24] => 2 [25] => 2 [26] => 11 [27] => 2 [28] => 4 [29] => 0 ) [Time connected] => Array ( [1] => 2251.375 [2] => 252.34375 [3] => 953.28125 [4] => 239.09375 [5] => 3504.65625 [6] => 889.6875 [7] => 952.75 [8] => 87.125 [9] => 47.96875 [10] => 193.5625 [11] => 91.4375 [12] => 619.40625 [13] => 950.125 [14] => 28.21875 [15] => 75.90625 [16] => 800.0625 [17] => 1294.75 [18] => 1183.84375 [19] => 953.25 [20] => 482.125 [21] => 1076.15625 [22] => 263.625 [23] => 73.03125 [24] => 689.40625 [25] => 676.34375 [26] => 940.625 [27] => 173.4375 [28] => 635.8125 [29] => 37.75 ) )


И еще сверху вот такую надпись.

Warning: Missing argument 2 for players(), called in /home/wm5142/domains/gameamx.ru/public_html/715kg/index.php on line 102 and defined in /home/wm5142/domains/gameamx.ru/public_html/715kg/index.php on line 73

В чем может быть проблема?
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.