Does anyone out there know how to use PHP to retrieve a number of statistics from a counter-strike (1.6) server??
Information like Server Players names, Frags, deaths, time spent on server in total and sort the players by frag to death ratio i.e. frags / deaths?

Ive come across a few interesting links but cant make ends meat of them of figure out how to get them working. I know a fair bit of PHP and SQL but can't seem to get any of the infomation from these following links working??

http://www.experts-exchange.com/Web/Web_Languages/PHP/PHP_Databases/Q_20767864.html
http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20939548.html

Just wondering if theres anyone who could help? Cheers for your time!

    Thats all good but when I try and get it running, it cant connect to the server! Ive tested with my own server and other servers, but its hard to tell whats causing the error. Has any one got any ideas?

      I just get "Error communicating with server" the error message thats written in to the else statement in the php code. 🙁

        Okay, do this:

        open the class. Where you see this:

        var $m_playerinfo        ="";        // Info about players
            var $m_servervars        ="";        // Info about the server current map, players etc
            var $m_serverrules  ="";        // Serverrules

        Add this:

        var $errmsg = ""; // Holds error message from server

        Now open the other file, the one that calls the server information. Look for:

        <? } else { ?>
        <tr>
          <td colspan="2">Error communicating with server</td>
        </tr>
        <? } ?>

        Replace with:

        <? } else { ?>
        <tr>
          <td colspan="2">Error communicating with server</td>
        </tr>
        <tr>
          <td>Error Message:</td><td><?php echo $csinfo->errmsg; ?></td>
        <? } ?>

        Now, what does that show?

        ~Brett

          the error message now reads

          Error communicating with server
          Error Message:


          Sourcefiles
          csstatus.php
          showplayers.php
          showrules.php
          counterstrike.php

          I get the impression that the scripts not even making contact with the server at all 🙁

            also if i open the show players page it displays this

            Notice: Undefined index: serveradr in c:\program files\easyphp1-8\www\cs\showplayers.php on line 10

            Notice: Undefined index: serverport in c:\program files\easyphp1-8\www\cs\showplayers.php on line 10

            Error communicating with server

            Close window

              Well, that's because it's looking for $_GET values from the URL. So if you make the link:
              domain.com/showplayers.php?serveradr=addres.of.server&serverport=port#
              it should try and connect and such.

              I'm not really sure. I say take this persons code, re-write it with more up-to-date standards (i.e. no short-tags, $_GET instead of $HTTP_GET_VARS, etc.) and see if that works.

              ~Brett

                Write a Reply...