Skip to main content

Query Source engine servers over UDP

Project description

Python Source Server Query Library

A Python package for communicating with a Source Engine Server over UDP

I push changes to the master branch whenever I finish a session of working on this. If you want the absolute latest version, download the code and use it manually, otherwise install through pip for the latest version I class as stable enough to use in your own projects.

Untested

  • Split package payload decompression
  • Split package size attribute detection
  • CS:GO servers with host_players_show set to 1 as I'm currently unable to find a server that uses this
  • Getting the players on a server running The Ship when someone is in the process of joining, as it relies on the count returned with the response packet, which may or may not differ from the actual number of players when someone is joining. (This descrepancy has not yet been observed on other servers despite the Valve dev wiki stating otherwise)

Installation

pip install sourceserver

Basic Usage

A SourceServer object acts as a connection to a Source engine server, with its own socket.
To instantiate a new SourceServer object, simply pass it a connection string in the form ipv4:port, the object will attempt to get the server's info, and if the connection fails after max retries, raises a SourceError.
Note, all errors that are expected are raised as SourceError, which marks the server as closed, but does not actually close the socket so the connection can be re-established.
The information regarding a server is retrieved each time you access the .info property, and is a dictionary in the form "info_type": "value".

A MasterServer object lets you query the Steam master servers, see the wiki for details

Example

>>> from sourceserver.sourceserver import SourceServer
>>> srv = SourceServer("89.35.29.5:27085")
Source Server @ 89.35.29.5:27085 | Connecting...
Source Server @ 89.35.29.5:27085 | Successfully established connection to server
>>> print(srv.info["game"]) 
Trouble in Terrorist Town
>>> print(srv.ping()) 
30.0
>>> print(srv.ping(2)) 
27.03
>>> count, players = srv.getPlayers()
>>> print(count)  
6
>>> print(players[0])
(0, 'Nbx3k', 17, 9938.7001953125)

Discord Server

https://discord.gg/aKDNstq

Discord Bot

https://github.com/Derpius/pythonsourceserverdiscordbot

License

GNU General Public License v3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sourceserver-0.10.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sourceserver-0.10.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file sourceserver-0.10.0.tar.gz.

File metadata

  • Download URL: sourceserver-0.10.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for sourceserver-0.10.0.tar.gz
Algorithm Hash digest
SHA256 00f13edbe04ebb28c60592aea6c2c48a0c402c14a983c6076a0a3bf38523df2f
MD5 b1608beb9982b5a8e1c80f63d64f44f3
BLAKE2b-256 ea7ae8fafc43e2fe232b83f286bb37d0816f18df41d5e4e1c392d7f8dc55c941

See more details on using hashes here.

File details

Details for the file sourceserver-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: sourceserver-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for sourceserver-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76a05da43a66fd710041c5b58225a83b17833ef7f35dfd89cff2656962be2ee7
MD5 0d6cfb877ecb51e229cfecdaa68b0654
BLAKE2b-256 910d6a0f946f21a56b559b143dd13d8ef79fa2ca2d2094e9d4a394946a60ff9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page