serverstf / python-valve

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

I need some support #69

Closed MauritsArissen closed 4 years ago

MauritsArissen commented 6 years ago

Hey guys I need some support, I am using this code and for some reason whenever I try to do anything with players I get an error

with valve.source.a2s.ServerQuerier(address=("208.103.169.207", 27015)) as server:
    stats = server.info()
    print("{}/{}".format(stats["player_count"], stats["max_players"]))
    for player in server.players()["players"]:
        print(player)

ERROR

Traceback (most recent call last):
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\messages.py", line 91, in validate
    raise ValueError
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/maris/PycharmProjects/discord/test.py", line 13, in <module>
    for player in server.players()["players"]:
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\a2s.py", line 198, in players
    challenge = messages.GetChallengeResponse.decode(self.get_response())
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\messages.py", line 415, in decode
    values[field.name], buffer = field.decode(buffer, values)
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\messages.py", line 41, in needs_buffer
    return func(self, buffer, *args, **kwargs)
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\messages.py", line 131, in decode
    struct.unpack(self.format, field_data)[0]), left_overs)
  File "C:\Users\maris\PycharmProjects\discord\venv\lib\site-packages\valve\source\messages.py", line 95, in validate
    value, self.name))
valve.source.messages.BrokenMessageError: Invalid value (68) for field 'response_type'`
Yepoleb commented 4 years ago

This is because the server sends the answer straight away without requiring a challenge. This is fixed in the byteio branch or python-a2s.