How make make an online Lobby
Author: | Solgryn
|
Submitted: | 5th June, 2009
|
Views: | 5474
| Rated: |
|
|
So, you want to make an online lobby for your game? A lobby where you can create games for other people to join? Let's go!
First of all, you need these objects for starters:
- List
- Edit box
- 2 buttons
- OINC client
The list will be the list of games available.
The edit box is the name of the game.
And the 2 buttons is join/create.
First of all connect to a server with OINC, you can probably read about this in othet tutorials.
Create a condition:
When button create is clicked
- set global string A to EditBox text (Memorizing the game name)
- OINC: send EditBox text on subchannel 1
- disable button join
- disable button create
- set EditBox text to (No text)
(Here you probably want to make a timer object to wait a little before going to next frame since there are some lag on servers)
- timer object set flag 0 on
Create a condition:
When timer object flag 0 is on
- timer object add 1 to alterable value A
Create a condition:
When timer object's alterable value A=>50(the number of wait time, for example 50 thats 1 second if you have 50 FPS)
- next frame
Second, when button create is clicked you will have to send a text on a subchannel, for example subchannel 1 (If you're not using that for anything else).
Send the text from your edit box and meanwhile, make the 2 buttons join and create disabled. Add a new line with the edit box text for yourself. Empty the edit box now.
Create a condition:
When text recieved on subchannel 1(The one you're using)
- LIST: add a new line in the list box (The text recieved)
Now you can see that someone created a game. Now you will have to connect to it.
Remember you must connect to a channel when you connect with OINC to chat/play with other players? We must take advantage of that because people cant see other people there are on a different channel than themselves.
Create a condition:
When (Len(List Select$(LIST))>0 AND button join clicked (The Len part is just to make sure that you wont join a game with no name, you cant do that.)
- disable button join
- disable button create
- set global string A to List Select$(LIST) (this is for memorizing the game name)
- next frame (or the game room frame)
Now, that was the lobby part.
Now to the game room.
In the game room you want to connect to the global string A, that's easy! Just connect like you usually do but when it asks you which channel you want to go to, just write Global string A.
And you're done!
Also, if you want a player limit for it just send a number to the channel and add it with each player that joins in, and if a player joins in when the number is the limit, have him send the text of the game to a subchannel 3 (another channel you aren't using) and when OINC recieves that, select delete a line in the LIST object and choose find string excact (message recieved)
Bye!
|
|
|