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

Can't get members in lobby. #38

Description

@WingsDevelopment

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);
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions