ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
204 stars 32 forks source link

Cant get members list or add bots to lobby #60

Closed SpOOnySk closed 3 years ago

SpOOnySk commented 3 years ago

Hello, Dont know if I am doing this right but I am trying to get list of all members that are in lobby and chceck if they are in the right team. I am getting lobby info as follows:

dota = Dota2Client(client)

@dota.on('ready')
def do_dota_stuff():
    msg = dota.create_practice_lobby("PW", None)

@channel.on('message')
def do_stuff(channel, message):
    dota.lobby.add_bot_to_practice_lobby(1, DOTA_GC_TEAM.GOOD_GUYS, DOTABotDifficulty.BOT_DIFFICULTY_PASSIVE)
    print(dota.lobby)

I get lobby info (id, mode, state ...) but no info on members (even there are players in lobby) and no bot get added into lobby when slot is empty. Any advice what am I doing wrong?

Got the newest update from github. Just downloaded this library 4 days ago.

rossengeorgiev commented 3 years ago

Just updated to the protos. Install from the repo, and let me know if it works. There should be new fields for members

SpOOnySk commented 3 years ago

Thank you so much, reinstalling package from github and not using pip install dota2 works, now I have list of members in lobby. I have one more question. When I am creating practice lobby and add options parameter it dosent work:

@dota.on('ready')
def do_dota_stuff():
    settings = {
        'game_name': 'Something Awesome - 2.0',
        "game_mode": DOTA_GameMode.DOTA_GAMEMODE_CM,
        "series_type": 2,
        "radiant_series_wins": 1,
        "dire_series_wins": 0,
        "pass_key": "PWA"
    }
    dota.create_practice_lobby(options=settings)

Lobby will be created but not with the settings above. Only way I can change the settings is by config_practise_lobby. I am just wondering if I am doing something wrong or is this a bug. Its not a problem to me to chagne setting with config_practise_lobby but I am just wondering what can be a problem here.

rossengeorgiev commented 3 years ago

Looking at the code it seems to be setting parameters. https://github.com/ValvePython/dota2/blob/20367840f5e49c80e46440da5573f2780b4e1e77/dota2/features/lobby.py#L66-L125

  1. The backed behavior may have changed, need to be verified against the client
  2. Do you wait for lobby update to comeback form the backend when you create the lobby? Messages are queued, when you use those methods as they only do send, so if you don't yield by doing io/idle/sleep haven't been sent yet.

A simple way to check is configuring debug logging and setting verbose_debug = True. Then calling create_practice_lobby and then doing like dota.sleep(5) and looking at the log output. Also, comparing with results from (1)

rossengeorgiev commented 3 years ago

Honestly, those create methods would be better if they implemented waiting for a response. Blocking that way would make them easier to use I think.

rossengeorgiev commented 3 years ago

Also, if you are installing with pip from the repo when you already have the package installed use pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/ValvePython/dota2

SpOOnySk commented 3 years ago

With dota.sleep(5) it is working right now. Thanks for your help. You can close this Issue now.