Answer the question
In order to leave comments, you need to log in
How to monitor cs go server discord.py?
Hello guys, I would like to implement monitoring of the cs go server in my bot, but I didn’t find any information about it. Lend a helping hand please
Answer the question
In order to leave comments, you need to log in
For monitoring, you need to make a request to the game server itself, using the valve a2s protocol. There are several libraries in python that implement this protocol: python-valve , python-a2s
Example python-value:
import valve.source.a2s
SERVER_ADDRESS = (..., ...)
with valve.source.a2s.ServerQuerier(SERVER_ADDRESS) as server:
info = server.info()
players = server.players()
print("{player_count}/{max_players} {server_name}".format(**info))
for player in sorted(players["players"], key=lambda p: p["score"], reverse=True):
print("{score} {name}".format(**player))
>>> import a2s
>>> address = ("stomping.kinofnemu.net", 27015)
>>> a2s.info(address)
SourceInfo(protocol=17, server_name=" 24/7 Dustbowl :: Nemu's Stomping Ground", map_name='cp_dustbowl',
folder='tf', game='Team Fortress', app_id=440, player_count=31, max_players=33, bot_count=21,
server_type='d', platform='l', password_protected=False, vac_enabled=True, version='5579073',
edf=177, port=27015, steam_id=85568392920040090, stv_port=None, stv_name=None,
keywords='brutus,celt,couch,cp,dustbowl,increased_maxplayers,nemu,nocrits,nodmgspread,pony,replays,vanilla',
game_id=440, ping=0.253798684978392)
>>> a2s.players(address)
[Player(index=0, name='Brutus', score=34, duration=836.4749145507812),
Player(index=0, name='RageQuit', score=6, duration=1080.8099365234375),
Player(index=0, name="Screamin' Eagles", score=1, duration=439.8598327636719)]
>>> a2s.rules(address)
{'coop': '0', 'deathmatch': '1', 'decalfrequency': '10', 'metamod_version': '1.10.7-devV',
'mp_allowNPCs': '1', 'mp_autocrosshair': '1', 'mp_autoteambalance': '0', 'mp_disable_respawn_times': '0',
'mp_fadetoblack': '0'}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question