Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2017-01-13 22:06:50, last edited by drunkbnu (2017-01-13 22:10:39)

drunkbnu
Formerly HG
Joined: 2017-08-16
Posts: 2,306

[Help] How to gather world title via room ID?

I'm recreating my old console chat client, this time with an option to browse all available rooms.

		public static void GetRooms () {
			Write ("Gathering rooms...");
			cli = PlayerIO.QuickConnect.SimpleConnect ("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null);
			RoomInfo[] rooms = cli.Multiplayer.ListRooms ("Everybodyedits" + cli.BigDB.Load ("config", "config")["version"], null, 0, 0);
			Clear ();
			Write (rooms.Length + " rooms available.\nUse up/down arrow keys to browse rooms, Press Enter to select a room.\n\n");
			foreach (RoomInfo room in rooms) {
				Write ("   " + room.Id + " - " + room.OnlineUsers + " users online.\n");
			}
			ReadKey (true);
		}

The code is supposed to show the room ID, and the users online. However, I would like to show the user the room name, since the user is allowed to browse and select their specific room (they don't have to copy any ID).

Offline

#2 2017-01-13 23:17:02

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [Help] How to gather world title via room ID?

HG wrote:

I'm recreating my old console chat client, this time with an option to browse all available rooms.

		public static void GetRooms () {
			Write ("Gathering rooms...");
			cli = PlayerIO.QuickConnect.SimpleConnect ("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null);
			RoomInfo[] rooms = cli.Multiplayer.ListRooms ("Everybodyedits" + cli.BigDB.Load ("config", "config")["version"], null, 0, 0);
			Clear ();
			Write (rooms.Length + " rooms available.\nUse up/down arrow keys to browse rooms, Press Enter to select a room.\n\n");
			foreach (RoomInfo room in rooms) {
				Write ("   " + room.Id + " - " + room.OnlineUsers + " users online.\n");
			}
			ReadKey (true);
		}

The code is supposed to show the room ID, and the users online. However, I would like to show the user the room name, since the user is allowed to browse and select their specific room (they don't have to copy any ID).

room.data["name"]
or something

Offline

#3 2017-01-13 23:43:25, last edited by drunkbnu (2017-01-13 23:44:02)

drunkbnu
Formerly HG
Joined: 2017-08-16
Posts: 2,306

Re: [Help] How to gather world title via room ID?

If you are going to answer to the entire topic, why would you quote it?

I was shared the method by capasha, which consists on gathering the name from RoomData.

foreach (RoomInfo room in rooms)
  Write ("   " + room.RoomData["name"] + (room.RoomData["name"].Length < 20 ? new string (' ', 20 - room.RoomData["name"].Length) : "" ) + " - " + room.OnlineUsers + " users online.\n");

Later I'll find my method to alphabetically sort rooms by name, then by online users.

Offline

#4 2017-01-14 00:05:09, last edited by LukeM (2017-01-14 00:19:55)

LukeM
Member
From: England
Joined: 2016-06-03
Posts: 3,009
Website

Re: [Help] How to gather world title via room ID?

HG wrote:

...some things...

Later I'll find my method to alphabetically sort rooms by name, then by online users.

Id use Linq, its not particularly fast or efficient, but is easy to do:

rooms = rooms.OrderBy(some lambda expression e.g. r => r.OnlineUsers or r => r.RoomData["name"]).toArray();

ps not sure if this works as I'm on my phone so didnt test it, but it should

Offline

LukeM1484348709642997

Board footer

Powered by FluxBB

[ Started around 1714171814.7026 - Generated in 0.045 seconds, 11 queries executed - Memory usage: 1.4 MiB (Peak: 1.51 MiB) ]