lfnetwork.com mark read register faq members calendar

Thread: Looking for Server Query Info
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 09-20-2005, 10:56 PM   #1
MyKell
Rookie
 
Join Date: Jun 2004
Location: Dallas, TX
Posts: 25
Looking for Server Query Info

This does not directly affect JA Coding, but seems like the most likely place to post...

I am working on an RCON program for JKA. I host 3 servers and monitor a couple other and have found the current RCON programs are just not enough.

I have a working RCON program based off RCON Commander from SEVERAL years ago. I have rewritten (not converted) in vb.net. I have a snappy display and can send and received RCON commands.

I would like to add monitoring area similar to what RCON Unlimited uses. From what I understand, RCON Unlimited queries the server for non RCON server info or configstrings. It returns a line to text in a format like this:

\sv_maxclents\20\sv_hostname\Jedi Knight\

I am very unsure of the info I would send the server or even where I would send it. I have been told I have to query a master server such as gamespy and I have been told I have to query the server directly.

Can anyone point me in the right direction? I have looked, but I am unsure how to proceed.

I am a medium programmer with HEAVY focus on inventory databases and accounting software. This game query stuff is new to me. Any code help in vb6 or vb.net would be wonderfull.

Thank you


MyKell
VB.net programmer
www.deseonet.com
MyKell is offline   you may: quote & reply,
Old 09-21-2005, 04:23 PM   #2
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
are you looking into doing it for PHP/ Perl or something else?

if php here's an example getstatus function which u can use:

Code:
function getstatus($server, $port = 29070)
{
    if (!($fd = @fsockopen("udp://$server", $port, $errno, $errstr, 3)))
        return FALSE;

    stream_set_timeout($fd, 3, 0);
    
    # challenge?
    
    fwrite($fd, "\xff\xff\xff\xffgetstatus " . rand());
    
    # getstatus reply should always come as a single (possibly
    # fragmented) datagram
    if (!($buf = @fread($fd, 4096))) {
        echo("Server is not responding<br>\n");
        return FALSE;
    }

    $parts = explode("\n", $buf);

    if ($parts[0] != "\xff\xff\xff\xffstatusResponse") {
        echo("bad response<br>\n");
        return FALSE;
    }
    
    # build an array of all the serverinfo keys
    $infostring = explode("\\", $parts[1]);
    array_shift($infostring);
    
    $side = 0;
    
    while (list($idx, $str) = each($infostring)) {
        if ($side == 0)
            $key = $str;
        else
            $info[$key] = $str;

        $side ^= 1;
    }
    
    # build an array of all the players
    # start by shifting off the response header and the serverinfo
    array_shift($parts);
    array_shift($parts);
	
    
    # and then looping through what's left
    while (list($idx, $str) = each($parts)) {
        if ($str == "")
            break;

        $playerparts = explode("\"", $str);
        $playerinfo = $playerparts[0];
        $name = $playerparts[1];
        
        $scoreping = explode(" ", $playerinfo);
        $score = $scoreping[0];
        $ping = $scoreping[1];
        
        $playerlist[$idx]['slot'] = $slot;
        $playerlist[$idx]['team'] = $team;
        $playerlist[$idx]['score'] = $score;
        $playerlist[$idx]['ping'] = $ping;
        $playerlist[$idx]['name'] = $name;
    }

    return array(info => $info, players => $playerlist);
}
u basically call something like this above all the printing stuff:

Code:
$ip = "your.ip.goes.here";
$port = "29070";
$status = getstatus($ip, $port);
to get a cvar u would do something like this:
Code:
<?php printf("%s", $status['info']['sv_hostname']); ?>
because there isnt another easy way to do this here's my example way of getting player count (not sure its 100% correct)

Code:
<?php
if ($status['players']) {
        uasort($status['players'], sort_by_score_desc);

		$playercount=0;
		while (list($idx, $curplayer) = each($status['players'])) {
			$playercount++;
    	}
		$status['info']['sv_currentclients']=$playercount;
}
?>
(just print out the sv_currentclients cvar if u use this method)


basically this is how i print out players:

Code:
       <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="100%">
         <tr>
           <td align="left"><font size="2" color="#EEEEEE"><b><u>Players</u></b></font></td>
           <td width="30" align="center"><font size="2" color="#EEEEEE"><b><u>Score</u></b></font></td>
           <td width="30" align="center"><font size="2" color="#EEEEEE"><b><u>Ping</u></b></font></td>
         </tr>
		 
		<?php
if ($status['players']) {
        uasort($status['players'], sort_by_score_desc);

		while (list($idx, $curplayer) = each($status['players'])) {
        printf(" <tr>\n<td align=left><font size=2>%s</font></td><td width=30 align=center><font size=2>%d</font></td><td width=30 align=center><font size=2>%d</font></td></tr>\n",
            $curplayer['name'],
            $curplayer['score'],
            $curplayer['ping']);
    	}
}
		?>
       </table>
now,,, you might want to colorize say the hostname or player names so:

Code:
<?php
$osp_colors = array(
    0 => "#666666", // to show black text on black bg...
    //0 => "#000000",
    1 => "#ff0000",
    2 => "#00ff00",
    3 => "#ffff00",
    4 => "#0000ff",
    5 => "#00ffff",
    6 => "#ff00ff",
    7 => "#ffffff", // maybe change this if you use a white bg
    8 => "#ff7f00",
    9 => "#7f7f7f",
    10 => "#bfbfbf",
    11 => "#bfbfbf",
    12 => "#007f00",
    13 => "#7f7f00",
    14 => "#00007f",
    15 => "#7f0000",
    16 => "#7f3f00",
    17 => "#ff9919",
    18 => "#007f7f",
    19 => "#7f007f",
    20 => "#007fff",
    21 => "#7f00ff",
    22 => "#3399cc",
    23 => "#ccffcc",
    24 => "#006633",
    25 => "#ff0033",
    26 => "#b21919",
    27 => "#993300",
    28 => "#cc9933",
    29 => "#999933",
    30 => "#ffffbf",
    31 => "#ffff7f"
);

function colorize($text)
{
    global $osp_colors;

    $curcolor = -1;
    $nextcolor = 7;
    
    for ($x = 0; $x < strlen($text); $x++) {
        if ($text[$x] == '^' && $text[$x + 1] != '^') {
            $nextcolor = (ord($text[$x + 1]) + 16) & 31;
            $x++;
            continue;
        }
        if ($curcolor != $nextcolor) {
            if ($curcolor != -1)
                $buf .= "</font>";
            $curcolor = $nextcolor;
            $buf .= sprintf("<font color=\"%s\">", $osp_colors[$curcolor]);
            
        }
		//$chars = "";
        $buf .= htmlspecialchars($text[$x]);
    }

    if ($curcolor != -1)
        $buf .= "</font>";
    return $buf;
}
just do something like this:

Code:
<?php printf("%s", colorize($status['info']['sv_hostname'])); ?>


iojamp project lead / coder

Last edited by ensiform; 09-21-2005 at 04:33 PM.
ensiform is offline   you may: quote & reply,
Old 09-21-2005, 04:27 PM   #3
Wudan
Got Balance?
 
Wudan's Avatar
 
Join Date: Oct 2002
Location: Salt Lake, UT
Posts: 1,442
On sf.net there's a project that has the PHP query script in it. Should be adaptable to any Quake3 engine game.


Mt-Wudan.com
I made a silly little program called Dragon, which is an animation tool for the GLA format, used in Jedi Outcast, Jedi Academy and Krakatoa.
Wudan is offline   you may: quote & reply,
Old 09-21-2005, 04:35 PM   #4
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
yes that script seems a little fishy when there's only 1 person in the server... it doesnt draw any players yet the sv_currentclients is 1.


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Old 09-24-2005, 02:19 PM   #5
stubert
 
Join Date: Aug 2002
Location: Philadelphia
Posts: 227
get a packet sniffer and run ja... you should know what words you have to send up and down then
stubert is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Looking for Server Query Info

Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:39 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.