I don't entirely understand how the lobby part works, so I'll probably have to copy it more or less wholesale.
There's just one change I need to make, but I don't know how:
How would I make it so that once two players have joined a game, that game is no longer visible/available to join, to other players? (my game will only support 2 players max.)
You might add an event to the clients that sends a message to the Lobby channel when the game starts, and tells the other clients to remove the game from the list. Another event could be added to boot other players if they try to join a full game by testing the number of peers upon connecting. If the number of peers is zero or one, then turn on a flag or something, and then if the number of peers is greater than 1 and that same flag is not already on, then disconnect.
You have 3 players in the lobby, 2 of which are about to join a game made by the 1st.
1st creates game:
when "create game button" clicked:
>send message 'gamename' to subchannel whatever
when peers recieve that message, they will add the name to a list object or whatever
now, peers can join that game by selecting the name and pressing join
this will send another message, also we indicate which game the peer wants to join by putting the game name in a string (we'll use that later):
when "join button" clicked:
>send message "I just joined"+'game name' to subchannel whatever
>set global string a to 'game name'
When theres enough players, the 1st will start the name. Notice theres only 1 peer joined, the second peer haven't joined the game yet.
the 1st player (The one who created the game) presses the start game button. And by that, he sends a message:
when "start game button" clicked:
>send message 'gamename' to subchannel whatever
>next frame
when a peer recieves that message, and their alterable string is == message, they will join the channel and go to next frame:
when message recieved == global string a:
(you could also send a message like 'I left the lobby to play 'game name' or something)
>next frame
when a peer that haven't joined the game recieved that message, we'll delete it from the list.
when message recieved <> global string a:
>list: delete line (Find string exact) 'message recieved'
also, have a disconnect at the end of frame
end of frame:
>disconnect
when the players go to the next frame, they will connect as usual but join the channel 'global string a' (the game name, remember?), this does that only those people
can see each other etc.
If theres something wrong, reply to this message =P just wrote it off the top of my head but thats basicly what I do...
I think I'm going to make that widget you talked about if I can =P
Hey that's my example! Yeah Solgryn pretty much explained it all For zombie swarm though I'm making a custom games lobby like in Halo 3 where you can invite people to your channel and play your own homemade maps/game types. It's gonna use multiple channels (like the lobby I made) and the stack feature to send your maps to the other players. So far you can invite anyone that's in the lobby to your game, talk to them, and they can view the maps
It's like 3 times harder than this lobby maybe I'll most my .mfa when I'm finished
Even though that tutorial was for OINC, it still is pretty much the same exact thing for lacewing. I even added commentary for that example What part don't you understand? I'll try to explain it to you.
Solgryn:
I looked at your article, and tried copying it, but I can't make it work. No games never appear in the list.
The other method you describe is a bit complicated too, with the "start" button and messages about who joined which game.
What's wrong here:
Sumo148:
Having player-names and game-names makes your example very complicated (too complicate dreally), but I think I more or less get it now.
Just the stuff under "lobby refresh" in the "Game Room" frame that I don't understand...
Anyone:
I'm really looking for something as simple as possible.
I want a player (no player names required) to be able to create a game, by entering a name and pressing "create" - in which case they will instantly go to the next frame, and the game name will appear in a list for anyone else playing.
I want other players to be able to join a game by picking the game name from a list amd pressing "join".
Once one player has joined a game (so 2 players total), I want the game to be removed from the list in the lobby.
An exampe would be amazing if anyone has the time...
Wow! That's brilliant - thankyou so much
I'll take a look at the code right after the hockey, but it seems to work perfectly.
btw: You should post that in the downloads section - I'm sure it would be helpful to a lot of people.
Solgryn, your example has a huge flaw :/ if a player joins the lobby (after you created a game), they won't be able to see the game that you created. That's what my example fixed with the "Lobby Refresh". During the game, if you're the host you will switch your channel to the lobby and test to see if a new peer connects. If he does, you will send your game information to that peer so he can be updated in the lobby...
Thats why my example seemed more complicated, because it used 2 channels. Also I just used the string parser 2 to split up the string so you can read the game name and the host of the game. It's not that complicated. Solgryn just combined the two using "Username - Game Name"
Big thanks to both of you - I've got a nice little system going now, which is very simple (didn't really need the chat etc) and which works nicely - even if someone enters the lobby after a game has been created