How to get server status with Python?


#1

Hi,
i want to wrire simple python script for server status. Looking for api, some doc or anything what could help me.


#2

This is my bash shell script to display the raw Quake3 server information: fetch-serverinfo

I’ll explain the quake 3 server status protocol but it’s up to you to figure out how to implement it using Python.

Different information is obtained from both getinfo and getstatus requests so applications often have to request both (using separate packets). Note however that gamename is different between them; gamename in infoResponse is name for dpmaster protocol but in statusReponse it’s set by mod (qagame.qvm) to mod directory.

getinfo

Send a UDP packet containing “\xFF\xFF\xFF\xFFgetinfo xxx” (where \xFF is a byte with value 255 and xxx can be a random challenge text) to a server (usually port 27960). The server will reply with “\xFF\xFF\xFF\xFFinfoResponse\n” (where \xFF is a byte with value 255 and \n is a newline character) followed by a Q3 info string (key and value pairs separated by a backslash).

Example infoResponse from phobos.ioquake3.org:27960:

\xFF\xFF\xFF\xFFinfoResponse
\voip\opus\g_needpass\0\pure\0\gametype\0\sv_maxclients\16\g_humanplayers\0\clients\2\mapname\q3dm7\hostname\server.ioquake3.org ioquake3 official\protocol\68\gamename\Quake3Arena\challenge\xxx

getstatus

Send a UDP packet containing “\xFF\xFF\xFF\xFFgetstatus xxx” to a server (usually port 27960). The server will reply with “\xFF\xFF\xFF\xFFstatusResponse\n” followed by a Q3 info string and player information on separate lines (score ping “name”). Ping 0 is either a bot or local player on a non-dedicated server.

Example statusResponse:

\xFF\xFF\xFF\xFFstatusResponse
\challenge\xxx\sv_allowDownload\1\sv_dlURL\http:\dmflags\0\fraglimit\25\timelimit\30\sv_hostname\server.ioquake3.org ioquake3 official\sv_maxclients\16\sv_minRate\0\sv_maxRate\10000\sv_dlRate\100\sv_minPing\0\sv_maxPing\0\sv_floodProtect\1\g_maxGameClients\0\capturelimit\8\version\ioq3 1.36_GIT_60a3112-2018-05-14 linux-x86_64 May 14 2018\com_gamename\Quake3Arena\com_protocol\71\g_gametype\0\mapname\q3dm7\sv_privateClients\0\bot_minplayers\2\gamename\baseq3\g_needpass\0
11 0 "Visor"
8 0 "Biker"

#3

Thx a lot man :slight_smile: