node-gamedig/reference/teeworlds/lgsl.txt

55 lines
2.2 KiB
Text
Raw Normal View History

/*----------------------------------------------------------------------------------------------------------\
| |
| [ LIVE GAME SERVER LIST ] [ <20> RICHARD PERRY FROM GREYCUBE.COM ] |
| |
| Released under the terms and conditions of the GNU General Public License Version 3 (http://gnu.org) |
| |
\-----------------------------------------------------------------------------------------------------------*/
function lgsl_query_21(&$server, &$lgsl_need, &$lgsl_fp)
{
//---------------------------------------------------------+
fwrite($lgsl_fp,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffgief");
$buffer = fread($lgsl_fp, 4096);
$buffer = substr($buffer, 20); // REMOVE HEADER
if (!$buffer) { return FALSE; }
//---------------------------------------------------------+
$server['s']['name'] = lgsl_cut_string($buffer);
$server['s']['map'] = lgsl_cut_string($buffer);
$server['e']['gamemode'] = lgsl_cut_string($buffer);
$server['s']['password'] = lgsl_cut_string($buffer);
$server['e']['progress'] = lgsl_cut_string($buffer)."%";
$server['s']['players'] = lgsl_cut_string($buffer);
$server['s']['playersmax'] = lgsl_cut_string($buffer);
switch ($server['e']['gamemode'])
{
case 0: $server['e']['gamemode'] = "Deathmatch"; break;
case 1: $server['e']['gamemode'] = "Team Deathmatch"; break;
case 2: $server['e']['gamemode'] = "Capture The Flag"; break;
}
//---------------------------------------------------------+
$player_key = 0;
while ($buffer)
{
$server['p'][$player_key]['name'] = lgsl_cut_string($buffer);
$server['p'][$player_key]['score'] = lgsl_cut_string($buffer);
$player_key ++;
}
//---------------------------------------------------------+
return TRUE;
}