How do I make a Room List in Construct 2?

Get help using Construct 2

Post » Mon Sep 12, 2016 5:49 am

How do I make a list that list all the current rooms and instances that people are hosting on my game?
They make a room at the log in screen but I want to know how to display all online/available rooms in the game on the login screen as well, like a server list for example and I want to know how to do this on something like the real-time multiplayer example.

I just can't figure out how to do this with the "Request room list" action.
B
27
S
12
G
5
Posts: 79
Reputation: 5,223

Post » Mon Sep 12, 2016 10:45 am

The manual is pretty clear... Which part don't you get?

You'll need an ”on room list" event, then you can get all the room information by expressions.

ListRoomCount
After On room list, the number of rooms in the received list.

ListRoomName(index)
ListRoomPeerCount(index)
ListRoomMaxPeerCount(index)
ListRoomState(index)
After On room list, retrieve information for a room at an index in the received list. The state can be one of "available", "locked" or "full".


You can use a loop for loopindex from 0 to multiplayer.listroomcount to go through each room by index.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Mon Sep 12, 2016 9:29 pm

oosyrag wrote:The manual is pretty clear... Which part don't you get?

You'll need an ”on room list" event, then you can get all the room information by expressions.

ListRoomCount
After On room list, the number of rooms in the received list.

ListRoomName(index)
ListRoomPeerCount(index)
ListRoomMaxPeerCount(index)
ListRoomState(index)
After On room list, retrieve information for a room at an index in the received list. The state can be one of "available", "locked" or "full".


You can use a loop for loopindex from 0 to multiplayer.listroomcount to go through each room by index.

I really have no idea of what to do, I've tried this and it still is not working, here's an image of what I'm doing.
Image
I don't know what I'm doing wrong I'm requesting the list and everything.
B
27
S
12
G
5
Posts: 79
Reputation: 5,223

Post » Tue Sep 13, 2016 7:15 am

So event number 9 is not running at all. Multiplayer.ListRoomCount cannot return a value until the room list has been received, but you call the request in that event. The second event will also never run because the request is never sent in the first place.

Try using another trigger to first request the room list.
Then, on room list received, repeat Multiplayer.ListroomCount times

RoomList Append text Multiplayer.ListRoomName(loopindex) & " - "Multiplayer.ListRoomPeerCount(loopindex) & newline
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Wed Sep 14, 2016 3:06 am

oosyrag wrote:So event number 9 is not running at all. Multiplayer.ListRoomCount cannot return a value until the room list has been received, but you call the request in that event. The second event will also never run because the request is never sent in the first place.

Try using another trigger to first request the room list.
Then, on room list received, repeat Multiplayer.ListroomCount times

RoomList Append text Multiplayer.ListRoomName(loopindex) & " - "Multiplayer.ListRoomPeerCount(loopindex) & newline

I tried that but it seems to not work. For some reason after it requests the rooms the list never gets received. Hope this image explains allot.
Image

EDIT:
this is the event sheet now and it has the same result.
Image
B
27
S
12
G
5
Posts: 79
Reputation: 5,223

Post » Wed Sep 14, 2016 7:47 am

Have you read the manual/multiplayer tutorials? It's not easy.

You're already missing about 4 steps. If you haven't done your homework, it's only going to get worse.. I figured this out with just a quick peek at the manual:

Connect
Connect to a signalling server. Upon successful connection, On connected will trigger.

On connected
Triggered after successfully connecting to the signalling server. In order to join rooms, it is necessary to next log in to the server.

Log in
Once connected, log in to the signalling server. Players must log in before they can join rooms. Upon a successful login, On logged in triggers.

On logged in
Triggered after the Log in action if the login is successful. Once logged in it is possible to join rooms. (yes, it literally mentions that on every single one of those manual entries)

NOW you can request the room list...
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Sep 14, 2016 11:46 am

Plus I see some weird events starting from your "on room list received".

Should be :

On room list received
If roomlistcount > 0
repeat roomlistcount times → Do stuff

And I think you don't even need to check roomlistcount value as if you request the room list, it means you are yourself in a room. So it will always be at least 1.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Thu Sep 15, 2016 7:44 pm

I got it working thanks for the help everyone
B
27
S
12
G
5
Posts: 79
Reputation: 5,223


Return to How do I....?

Who is online

Users browsing this forum: Christmas, dop2000, Hyune and 16 guests