Jump to content
  • 0
Lethal Raptor Games

Lobby::Count()

Question

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

 

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 0
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

Share this post


Link to post
  • 0

The other fun end of that, which happened to me, is when random people join your lobby while you're testing, since their programs don't test for any keys you may set.  😛

  • Haha 1

Share this post


Link to post
  • 0

It would probably cause a crash somewhere along the line too, as they wont be sending the same data as you.    Maybe when a client joins we test to see if they are running the same game or not.  🤔

Share this post


Link to post
  • 0

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   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.

×
×
  • Create New...