Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Can't get members in lobby. #38

Open
WingsDevelopment opened this issue Sep 15, 2021 · 3 comments
Open

Can't get members in lobby. #38

WingsDevelopment opened this issue Sep 15, 2021 · 3 comments

Comments

@WingsDevelopment
Copy link

WingsDevelopment commented Sep 15, 2021

I don't know when to start lobby, because lobby.members always returns 0 members.. And I don't get why? Can anyone help me with this?
public void CreateLobby(string LobbyName, string LobbyPassword, ulong[] Radiant, ulong[] Dire)
{

        if (dota.Lobby != null)
        {
            UpdateStatus(DotaClientStatus.Warning, "Lobby: Creating a lobby when already in one.");
        }


        CMsgPracticeLobbySetDetails details = new CMsgPracticeLobbySetDetails();
        details.game_name = LobbyName;
        details.pass_key = LobbyPassword;
        details.game_mode = (uint)DOTA_GameMode.DOTA_GAMEMODE_AP; // game mode
        details.allow_cheats = true; // chitz
        details.server_region = (uint)ERegionCode.USEast;
        details.dota_tv_delay = LobbyDotaTVDelay.LobbyDotaTV_300;
        details.game_version = DOTAGameVersion.GAME_VERSION_CURRENT;
        details.visibility = DOTALobbyVisibility.DOTALobbyVisibility_Public;

        dota.CreateLobby(LobbyPassword, details);

        // wait for lobby to be created
        while (dota.Lobby == null)
        {
            Thread.Sleep(10);
        }
        UpdateStatus(DotaClientStatus.Normal, "Lobby: Lobby Created.");
        UpdateStatus(DotaClientStatus.Normal, "Lobby: Lobby Name: " + LobbyName);
        UpdateStatus(DotaClientStatus.Normal, "Lobby: Lobby Password: " + LobbyPassword);
        UpdateStatus(DotaClientStatus.Normal, "Lobby: Lobby ID: " + dota.Lobby.lobby_id.ToString());

        Thread.Sleep(1000);
        foreach (var p in Radiant)
        {
            dota.InviteToLobby(p);
        }
        foreach (var p in Dire)
        {
            dota.InviteToLobby(p);
        }
        dota.JoinCoachSlot(DOTA_GC_TEAM.DOTA_GC_TEAM_GOOD_GUYS);
        dota.Lobby.allow_spectating = true;

        UpdateStatus(DotaClientStatus.Normal, "Lobby: Moved bot to player pool.");

        if (OnLobbyCreated != null)
        {
            OnLobbyCreated(dota.Lobby.lobby_id);
        }

        UpdateStatus(DotaClientStatus.Normal, "Lobby: Waiting for players to connect....");

        List<DateTime> NotificationTimeouts = new List<DateTime>();
        NotificationTimeouts.Add(DateTime.Now.AddMinutes(1));
        NotificationTimeouts.Add(NotificationTimeouts.Last().AddMinutes(1));
        NotificationTimeouts.Add(NotificationTimeouts.Last().AddMinutes(1));
        NotificationTimeouts.Add(NotificationTimeouts.Last().AddMinutes(1));
        NotificationTimeouts.Add(NotificationTimeouts.Last().AddMinutes(1));
        NotificationTimeouts.Reverse();

        while (true)
        {
            List<CDOTALobbyMember> members = dota.Lobby.members;

            int count = 0;

            Console.WriteLine("Count :" + dota.Lobby.members.Count);
            if (count == 1)
            {
                break;
            }
            Thread.Sleep(1000);

            if (NotificationTimeouts.Count == 0)
            {
                continue;
                //TODO: cancel the match and reset bot
            }

            if (DateTime.Now > NotificationTimeouts[0])
            {
                dota.SendChannelMessage(dota.Lobby.lobby_id, "Players have " + NotificationTimeouts.Count.ToString() + " minute" + (NotificationTimeouts.Count == 1 ? "" : "s") + " to join the lobby.");
                NotificationTimeouts.RemoveAt(0);
            }
        }
@WingsDevelopment
Copy link
Author

WingsDevelopment commented Sep 15, 2021

I think I found the problem. CSODOTALobby -> 'members' should be named 'all_members' to be able to fetch json from dota2 api
CSODOTALobby ->
[ProtoMember(2, Name = "members", DataFormat = DataFormat.Default)]
public List members { get; }
But this class is locked for me... Can anyone help me with this please?

@sbx320
Copy link
Contributor

sbx320 commented Sep 15, 2021

You likely need to update the Protobuf definitions, which define the network messages. The last update in this repo is from 2019, so any change Valve made after that aren't reflected in the last NuGet release.

@WingsDevelopment
Copy link
Author

I'm sorry, can you be more clear? How do I update Protobuf definitions? And what are Protobuf definitions? Can you send me some guide for that please?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants