HalfLife/Cstrike monitorring

G

Guyon Morée

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
 
T

Terry Reedy

Guyon Morée said:
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
 
E

Erik Max Francis

Guyon Morée said:
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.
 
G

Guyon Morée

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
 
P

Paul Clinch

Guyon Morée said:
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

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.


Regards, Paul Clinch
 
S

Steve Lamb

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. :)
 
E

Erik Max Francis

Steve said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top