Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- https://python-valve.readthedocs.io/en/latest/index.html
- """
- from unicodedata import normalize
- from valve.source.a2s import ServerQuerier
- def query(ip, port=None):
- if ":" in ip and port is None:
- ip, port = ip.split(":")
- port = int(port)
- with ServerQuerier((ip, port)) as server:
- info = server.info()
- players = server.players()
- players = [
- (normalize("NFKC", player["name"]), player["score"])
- for player in sorted(players["players"], key=lambda i: i["score"], reverse=True)
- ]
- print(info["server_name"])
- print("Max players:", info["max_players"])
- print("Current Players:", len(players))
- print("="*30)
- for player, score in players:
- print(player.ljust(25), str(score).rjust(4))
- query("5.9.8.124:10032")
Add Comment
Please, Sign In to add comment