serverstf / python-valve

A Python Interface to various Valve products and services
Other
235 stars 71 forks source link

Vanilla Counter-Strike:Global Offensive server returns invalid value in response_type #29

Open fantoms opened 8 years ago

fantoms commented 8 years ago

An error producing issue was observed after creating 3 brand new CS:GO servers. If host_players_show does not equal 2, responses using the following code are returning a BrokenMessageError exception:

# !/usr/bin/python3.4

import time
import valve.source.a2s

address = ('65.103.35.106', 27015)

while(True):
  try:
      server = valve.source.a2s.ServerQuerier(address)
      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))
  except valve.source.messages.BrokenMessageError as ErrorMsg:
      print("!******\* Broken server response ********! " , ErrorMsg)
  except valve.source.a2s.NoResponseError:
      print("Server request timed out!")
  time.sleep(1)

Error string from BrokenMessageException: Invalid value (68) for field 'response_type'

The issue was resolved remotely by setting a host cvar variable on the cs:go server cfg file to allow for "old format" player reporting: host_players_show 2

To duplicate this error set host_players_show 1

Warning:CS:GO Server by default returns only max players and server uptime. You have to change server cvar "host_players_show" in server.cfg to value "2" if you want to revert to old format with players list

Valve reference: https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER

Yepoleb commented 7 years ago

The problem here is that the server sends the player response right away without requiring a challenge number. It will be fixed once https://github.com/serverstf/python-valve/commit/cdf5bd9b77dc7f2d4e8dc4fe3efe93bc871e6d32 is merged.