[Script] Qstat xml to html

vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
edited May 2011 in Modding
A friend write a code with JQuery to transform the .xml from qtstat to a readable .html file.

<b><u>How it works ? :</u></b>

<u>1/ Create a .bat file and put the code from the "1st Part" into it.</u>

edit1 : you will maybe need to change the two paths (set path_qstat= and set path_browser=) if you put qstat and your browser into other path than mine.
edit2 : Change the @IP with your server ip.

<u>2/ Create a .html file and put the code from the "2nd Part" into it.</u>

edit : if you want to change the name of the file result.xml, you'll need to change the value of url: "result.xml", at ligne 11 from html code

<u>3/ Launch the .bat file</u>
<u>4/ Profit.</u>

<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->
<b>1st Part = Here is the command line of qstat (in a .bat file) :</b><!--sizec--></span><!--/sizec-->

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->@echo off

::path
set path_qstat="c:\Users\%username%\Desktop\ns2server_Desktop\applications\qstat-2.11-win32"
set path_browser="c:\Program Files (x86)\Mozilla Firefox"

::exe
set qstat=%path_qstat%\qstat.exe
set browser=%path_browser%\firefox.exe

::index
set index=%path_qstat%\index.html

::create xml file
%qstat% -a2s 88.190.18.171:27017 -R -P -xml -of %path_qstat%\result.xml

::print
%browser% %index%<!--c2--></div><!--ec2-->

<!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo--><b>2nd Part = Here is the code to put into a index.html :</b><!--sizec--></span><!--/sizec-->

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<html>
<head></head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>

$(document).ready(  
function()
{
   $.ajax( {
            type: "GET",
            url: "result.xml",
            dataType: "xml",
            success: function(xml)
                     {
                    
                    
                       $(xml).find('server').each(  
                         function()
                         {

                            // recupere le hostname (une valeur)
                            var hostname = $(this).find('hostname').text();
                            var name = $(this).find('name').text();
                            var gametype = $(this).find('gametype').text();
                            var map = $(this).find('map').text();
                            var numplayers = $(this).find('numplayers').text();
                            var maxplayers = $(this).find('maxplayers').text();
                            var ping = $(this).find('ping').text();
                            var retries = $(this).find('retries').text();
                            
                            $('<div></div>').html("<h1> Information Générale </h1>").appendTo('#Div_XML');;
                        
                            $('<div id="hostname"></div>').html("<b>Hostname : </b>" + hostname).appendTo('#Div_XML');
                            $('<div id="name"></div>').html("<b>Name : </b>" + name).appendTo('#Div_XML');
                            $('<div id="map"></div>').html("<b>map : </b>" + map).appendTo('#Div_XML');
                            $('<div id="numplayers"></div>').html("<b>numplayers : </b>" + numplayers).appendTo('#Div_XML');
                            $('<div id="maxplayers"></div>').html("<b>maxplayers : </b>" + maxplayers).appendTo('#Div_XML');
                            $('<div id="ping"></div>').html("<b>ping : </b>" + ping).appendTo('#Div_XML');
                            $('<div id="retries"></div>').html("<b>retries : </b>" + retries).appendTo('#Div_XML');
                            $('<div id="gametype"></div>').html("<b>gametype : </b>" + gametype + "

").appendTo('#Div_XML');
                            
                            $('<div></div>').html("<h1> Information Technique </h1>").appendTo('#Div_XML');;
                            
                            // recupere un élément précis du tag rules (marche pas)
                            $(this).find('rule').each(
                                function()
                                            {
                                            var name = $(this).attr('name');
                                          
                                            var tickrate = $(this).text();
                                            $('<div id="rules"></div>').html("<b>" + name + "</b> <b>:</b> " +tickrate).appendTo('#Div_XML');
                                          
                                            });
                          });
                      }
        });
  }
);
</script>
<body>
<div id="Div_XML"></div>
</body>
</html><!--c2--></div><!--ec2-->

<b><!--sizeo:4--><span style="font-size:14pt;line-height:100%"><!--/sizeo-->Here is an example<!--sizec--></span><!--/sizec--></b>

<img src="http://images3.photomania.com/1024992/1/rad1B823.png" border="0" class="linked-image" />

Comments

  • vizioNzvizioNz InversionNS2.com Join Date: 2003-12-21 Member: 24595Members, Constellation, NS2 Playtester
    Thank you for this buddy, this was a little hidden gem.
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    Thanks vizioNz, I'm glad it helps someone.
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    edited March 2012
    Something changed ?

    Here is the result now (lot of info missing compare to <a href="http://images3.photomania.com/1024992/1/rad1B823.png" target="_blank">example</a>) :

    General Information
    Hostname : 86.29.8.188:27016
    Name : duplexgaming.co.uk #1
    map : ns2_summit
    numplayers : 13
    maxplayers : 14
    ping : 56
    retries : 2
    gametype : naturalselection2

    Technical Information
    protocol : 11
    gamedir : naturalselection2
    gamename : Natural Selection 2
    dedicated : 1
    sv_os : windows
    password : 1
    secure : 1
    version : 1.0.0.0
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    And I guess another copy-paste can't hurt:

    <!--quoteo(post=0:date=:name=me)--><div class='quotetop'>QUOTE (me)</div><div class='quotemain'><!--quotec-->Yar, QStat has issues with NS2's own query-responder for not adhering strictly to the query-protocol (which is surprising), it has to do with QStat demanding a challenge for the rule\player-reply, which NS2 does not give, rather you're supposed to just directly request the data. GameOvermind's QR did both the challenge- and the direct-approach.

    Enough of the jibber jabber, what you need to do is query all the servers directly (no need to look a port above or under anymore), and lift the tickrate- and ns2build-information from the gametags-field. It is part of the general-reply (the one that contains the server-name\maxslots et cetera), and looks like: build|gamemode|tickrate %. The uptime-information isn't exposed through it, so that won't be available anymore for the moment, though you don't have to remove the code associated with getting that data from the rules-reply, as when the rewrite of GM is done (in 2020), it'll work again with QStat.

    Upside to all this for the moment, is that you can fetch the tickrate-data of all servers that run GM per definition (gives an insight into how many servers actually run it at this point).<!--QuoteEnd--></div><!--QuoteEEnd-->
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    Ty for the informations player
Sign In or Register to comment.