Jump to content

How does the game connect to a server?

Recommended Posts

Hey guys,

I'm a coding newbie trying to learn JKA code... apologies if the question seems silly but I wanted to know how can I fetch a list of all active servers and server details like how many players are in the server, etc. from outside of the game? For example, if I have a server IP... how do I get the server information from the IP? I was thinking of writing something in TypeScript but like I said I'm a complete newbie so any help is appreciated.

Link to comment

All right, I'm actually on my computer now, so I can give a proper answer.

This only applies to getting data from a single game server - if you're looking to get a list of server addresses, that is beyond my knowledge, but I know it isn't hard. I believe JKHub runs a master server you can use for that.


Anyhow, for individual server data, here's what ParaTracker does...

Make sure you're using UDP for the connection, Q3 servers have no idea what TCP is.

When tracking a server, ParaTracker creates a getstatus query with the following code:

str_repeat(chr(255),4) . chr(02) . "getstatus\n"

Basically, this boils down to:

Four chr(255), followed by a single chr(2), the string "getstatus", and a line break. (There are other working methods, but I found that this method gives maximum compatibility across different games. For instance, Nexuiz Classic does not like this method, so I believe you have to remove the chr(2) for it to work).

The final string should look like this:

Send that command to the game server of your choice over UDP.

If you are using Javascript/node.js, you will need to wrap the string with Buffer.from() before sending it.

If all went well, you will receive a text dump that looks something like this:

\version\JAmp: v1.0.1.0 linux-x86_64 Oct 20 2020\v\2.6B1\timelimit\0\sv_privateClients\0\sv_minRate\0\sv_minPing\0\sv_maxclients\16\sv_maxRate\0\sv_maxPing\0\sv_hostname\^1Parabolic ^9[^8ja.dogi.us^9]\sv_fps\60\sv_floodProtectSlow\1\sv_floodProtect\0\sv_autoDemo\0\sv_allowDownload\1\ssf\5F\protocol\26\pmove_overbounce\1\mapname\sithcouncilv2\jp_gripSpeedScale\0.4\jp_cinfo\32\japp_version\JA++, 64 bits, May 30 2019, 78feacf\japp_unlagged\0\gamename\JA+ Mod v2.6 B1\g_weaponDisable\0\g_stepSlideFix\1\g_siegeTeamSwitch\1\g_siegeTeam2\none\g_siegeTeam1\none\g_siegeRespawn\20\g_showDuelHealths\0\g_saberLocking\1\g_privateDuel\1\g_noSpecMove\0\g_needpass\0\g_maxHolocronCarry\3\g_maxForceRank\7\g_jediVmerc\0\g_gametype\0\g_forcePowerDisable\0\g_forceBasedTeams\0\g_duelWeaponDisable\1\g_debugMelee\0\fraglimit\500000\duel_fraglimit\10\dmflags\0\capturelimit\5\bot_minplayers\0\bg_fighterAltControl\0
22 132 "TIPO"
0 0 "^0w^7S^0w^1|^0e^7V^0ilkill^7E^0"
2 0 "^1s^0|^7papa"
0 0 "^0D^7|^0S J^7o^0n^7e^0s"
0 0 "^0one^1.^7conker"
3 0 "^5-^0a^5-^7illumi^5na"
0 0 "^0cK ^7inmojo*"
12 0 "^2KiH^4.^7FeTTe^7"
9 0 "^0w^7S^0w^1|^0l^7a^0ws^1_^769"
1 0 "^1-^0Tv^1-^7doNka"
9 0 "^4iN^3-^7SoD^3!"
8 0 "^0-^7o^2p^7p H^2y^7drO^0-"


The first line is four chr(255), followed by a string telling you what the server is sending you (statusResponse).

The second line is all the CVars, delimited with backslashes like so:


After a line break, the player info begins. There is a line break between each player's info, the data is delimited with spaces, and player names are in quotes:

score ping team(Only appears if teams are applicable) "name"


One other important thing to note, is that Q3 games use ANSI encoding, not ASCII or Unicode. It would be a good idea to convert the data to Unicode if you're putting it on a web page.

Good luck!

Smoo likes this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...