Jump to content

Lobby::Count()


SpiderPig
 Share

Go to solution Solved by SpiderPig,

Recommended Posts

When I call Lobby::Count() it retrieves a 49 lobbies.  I think I'll have to use one of the overloads and pass a string attribute that looks for lobbies made for only the current game?

int _totalLobbies = Lobby::Count();
for (int id = 0; id < _totalLobbies; id++) {
	auto _lobby = Lobby::Get(id);
	if (_lobby != nullptr) {
		int _totalMembers = _lobby->CountMembers();
		int _maxPlayers = 32;

		std::string _name = _lobby->GetString("lobbyname");
		std::string _lobbyName = String(id) + " : " + _name + " " + String(_totalMembers) + "/" + String(_maxPlayers);
		Lobbies.push_back(_lobbyName);
	}
	else {
		MessageBox(Window::GetCurrent()->GetHandle(), "Could not load Lobby!", "Error", MB_OK);
	}
}

 

Link to comment
Share on other sites

  • Solution
Quote

Creating a new lobby to advertise our game is easy. We just call a command to create it, and then we will set two string values. The game title is set so that we can later retrieve only lobbies that are running this particular game. (This should be done if you are using the SpaceWar app ID instead of your own Steam ID.) We also add a short description that can display information about the game.

I should read more often.

  • Like 1
  • Haha 1
Link to comment
Share on other sites

Pretty much.  You can have the client send an ID # you made up as the very first packet after they connect.  If the host receives this number, it accepts the client into the game.  Otherwise, it doesn't let them play.  They'll still be in the lobby (I don't think a host can remove a client from a lobby) but you treat them as if they're not.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...