HalfLife/Cstrike monitorring

Discussion in 'Python' started by Guyon Morée, Dec 11, 2003.

  1. Guyon Morée

    Guyon Morée Guest

    Hi all,

    I want to write a HalfLife/CStrike monitor, to make some nice statistics for
    an upcoming LAN-party. I've found some pointers on how to use the protocol,
    but now I have to do the following:

    1. make an UDP connection
    2. send a string(?) like '\xFF\xFF\xFF\xFFdetails\x00'
    3. translate the response into bytes and strings :-s

    for more details on this protocol see:
    http://dev.kquery.com/index.php?article=31

    I hope someone can help me with at least the first 2 steps.

    Thanx,

    Guyon
    Guyon Morée, Dec 11, 2003
    #1
    1. Advertising

  2. Guyon Morée

    Terry Reedy Guest

    "Guyon Morée" <> wrote in message
    news:3fd84154$0$251$...
    > Hi all,
    >
    > I want to write a HalfLife/CStrike monitor, to make some nice statistics

    for
    > an upcoming LAN-party. I've found some pointers on how to use the

    protocol,
    > but now I have to do the following:
    >
    > 1. make an UDP connection
    > 2. send a string(?) like '\xFF\xFF\xFF\xFFdetails\x00'
    > 3. translate the response into bytes and strings :-s
    >
    > for more details on this protocol see:
    > http://dev.kquery.com/index.php?article=31
    >
    > I hope someone can help me with at least the first 2 steps.


    Try Googling 'Python HalfLife monitor' (200+ hits). 'Python UDP monitor'
    gets you to more general info (first is UDP support in Twisted).

    TJR
    Terry Reedy, Dec 11, 2003
    #2
    1. Advertising

  3. "Guyon Morée" wrote:

    > I want to write a HalfLife/CStrike monitor, to make some nice
    > statistics for
    > an upcoming LAN-party. I've found some pointers on how to use the
    > protocol,
    > but now I have to do the following:
    >
    > 1. make an UDP connection
    > 2. send a string(?) like '\xFF\xFF\xFF\xFFdetails\x00'
    > 3. translate the response into bytes and strings :-s
    >
    > for more details on this protocol see:
    > http://dev.kquery.com/index.php?article=31
    >
    > I hope someone can help me with at least the first 2 steps.


    It sounds like you just want a server statistics package, of which there
    are many available. See Google; a good one is PsychoStats. There's
    really no need for you to reinvent the wheel here.

    --
    __ Erik Max Francis && && http://www.alcyone.com/max/
    / \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    \__/ Dead men have no victory.
    -- Euripides
    Erik Max Francis, Dec 11, 2003
    #3
  4. Guyon Morée

    Guyon Morée Guest

    Thanx for the tip, but actually I wanted to make something, which shows the
    stats of a match a bit 'flashy arcade style'. perhaps i'll use pygame for
    that part.

    In other words: it should look cool on a beamer :)

    anyway, the decoding stuff I've managed, but I'm still stuck with the UDP (i
    think) because somehow no response is given. maybe someone can show me the
    light.

    thanx,

    Guyon


    "Erik Max Francis" <> schreef in bericht
    news:...
    > "Guyon Morée" wrote:
    >
    > > I want to write a HalfLife/CStrike monitor, to make some nice
    > > statistics for
    > > an upcoming LAN-party. I've found some pointers on how to use the
    > > protocol,
    > > but now I have to do the following:
    > >
    > > 1. make an UDP connection
    > > 2. send a string(?) like '\xFF\xFF\xFF\xFFdetails\x00'
    > > 3. translate the response into bytes and strings :-s
    > >
    > > for more details on this protocol see:
    > > http://dev.kquery.com/index.php?article=31
    > >
    > > I hope someone can help me with at least the first 2 steps.

    >
    > It sounds like you just want a server statistics package, of which there
    > are many available. See Google; a good one is PsychoStats. There's
    > really no need for you to reinvent the wheel here.
    >
    > --
    > __ Erik Max Francis && && http://www.alcyone.com/max/
    > / \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    > \__/ Dead men have no victory.
    > -- Euripides
    Guyon Morée, Dec 11, 2003
    #4
  5. Guyon Morée

    Paul Clinch Guest

    "Guyon Morée" <gumuz*NOSP@M*looze.net> wrote in message news:<3fd8fa1c$0$154$>...
    > Thanx for the tip, but actually I wanted to make something, which shows the
    > stats of a match a bit 'flashy arcade style'. perhaps i'll use pygame for
    > that part.
    >
    > In other words: it should look cool on a beamer :)
    >
    > anyway, the decoding stuff I've managed, but I'm still stuck with the UDP (i
    > think) because somehow no response is given. maybe someone can show me the
    > light.
    >
    > thanx,
    >
    > Guyon
    >
    >
    > "Erik Max Francis" <> schreef in bericht
    > news:...
    > > "Guyon Morée" wrote:
    > >
    > > > I want to write a HalfLife/CStrike monitor, to make some nice
    > > > statistics for
    > > > an upcoming LAN-party. I've found some pointers on how to use the
    > > > protocol,
    > > > but now I have to do the following:
    > > >
    > > > 1. make an UDP connection
    > > > 2. send a string(?) like '\xFF\xFF\xFF\xFFdetails\x00'
    > > > 3. translate the response into bytes and strings :-s
    > > >


    UDP is connectionless, make a socket, send and recv.

    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.sendto('\xFF\xFF\xFF\xFFdetails\x00', ('127.0.0.1', portnumber ))
    ret, addr = s.recvfrom(1024)

    Note that the server is not guaranteed to receive your request, or you
    receive the reply.
    Look up select and poll in the doc.s. Python version 2.3 has socket
    timeouts.

    > > > for more details on this protocol see:
    > > > http://dev.kquery.com/index.php?article=31
    > > >
    > > > I hope someone can help me with at least the first 2 steps.

    > >
    > > It sounds like you just want a server statistics package, of which there
    > > are many available. See Google; a good one is PsychoStats. There's
    > > really no need for you to reinvent the wheel here.
    > >
    > > --
    > > __ Erik Max Francis && && http://www.alcyone.com/max/
    > > / \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    > > \__/ Dead men have no victory.
    > > -- Euripides



    Regards, Paul Clinch
    Paul Clinch, Dec 12, 2003
    #5
  6. Guyon Morée

    Steve Lamb Guest

    On 2003-12-11, Erik Max Francis <> wrote:
    > It sounds like you just want a server statistics package, of which there
    > are many available. See Google; a good one is PsychoStats. There's
    > really no need for you to reinvent the wheel here.


    Not true. Psycho stats does not, for example, take the details given by
    the connection and translate it into something MRTG or LRRD can parse for a
    general graph of players per time unit. Furthremore Psycho works on the logs
    not on the udp interface.

    With that said I'd recommend the person just sit down with a good Python
    book and hammer at it. Took me about 10m to get my script working to query
    just what he was asking for and translate the results into information I
    needed. Prior to that I had never worked with network code in any language.
    The major boon was being able to play with code interactively. :)

    --
    Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
    PGP Key: 8B6E99C5 | main connection to the switchboard of souls.
    -------------------------------+---------------------------------------------
    Steve Lamb, Dec 16, 2003
    #6
  7. Steve Lamb wrote:

    > Not true. Psycho stats does not, for example, take the details
    > given by
    > the connection and translate it into something MRTG or LRRD can parse
    > for a
    > general graph of players per time unit. Furthremore Psycho works on
    > the logs
    > not on the udp interface.


    At this point I don't know what the original poster wanted; he said he
    wanted a "monitor, to make some nice statistics for an upcoming
    LAN-party." He certainly never said anything about requiring MRTG or
    LRRD capability, and I don't know where you're getting that.

    PsychoStats and similar log processing packages will be more than
    sufficient for the task of giving some interesting statistics during a
    LAN party. The fact that he started talking about trying to get UDP to
    work doesn't necessarily indicate to me that's a coherent solution to
    his problem, just that's the road he took.

    If he wants to analyze the status of the game in realtime, i.e., ping
    the current server activity to see what's happening, he can use qstat (a
    standalone application), for which I've already written a Python wrapper
    (PyQstat):

    http://www.alcyone.com/software/qstat/

    Although you can get information like how long players have been on the
    server, what their current scores are, etc., you simply cannot get the
    level of detail involved in actually processing logs.

    Even if he were to write a complete dummy client from scratch that
    merely spectated in order to try to collect as much information as
    possible (which is not a trivial task), it's unlikely he would get the
    level of detail he would be satisfied with, since information given to
    an individual client is in some sense "unprivileged," whereas the server
    logs are by contrast "privileged," since the server knows everything
    that is going on in the game. The server logs will contain more
    information than he can get via any playing around with UDP; if he wants
    pseudorealtime status, he can just run the log processor on small log
    files (not a problem since it's going to be for a LAN party) every
    minute or so.

    --
    __ Erik Max Francis && && http://www.alcyone.com/max/
    / \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    \__/ It is impossible to love and be wise.
    -- Francis Bacon
    Erik Max Francis, Dec 16, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page