How to check if server is still available and is full

I wouldn’t make the introduction long so Ill get to the point,

Basically I would like to make a lobby system, supposed that when a player press the create lobby button, it would basically create a lobby, ofc lol and it will redirect that player to the lobby he made trough a server,

  • When the player creates a lobby, and a player wishes to join that lobby, the system need to check if the server is still available and is it full ("Ik that even if the server it’s full it will still redirect you to the game but it will show you an error “Server is full”, I would not like the player to waste his time on trying to teleport the game only to show its full). But I do not know how to send data trough that place,

I tried making the use of “Messaging Service” and researched about it for the past few hours but the topics that are supposed to answer my questions are left unanswered and ghosted.

My question is, how do I achieve this, also please don’t send code that will get straight to the system, send code if its only a sample of how to do something. I would like an interpreted answer. Thanks

1 Like

I’ve made a lobby recently and the way I did it was as follows:

Have 2 datastores, one is ordered and the other is regular. In the ordered data store, set the key to the JobId of the server and the value to whatever. In the second normal datastore, set the key to the JobId as well and the value to whatever static data is needed, e.g. Server name, password, region, max players, etc things that dont change.

Then, in the lobby game, use GetPagesAsync on the ordereddatastore to get a list of all the online servers. You can get the key of this ordereddatastore than use GetAsync on the regular datastore to get all the static data. Note: The data doesn’t nessescarily have to be static, it’s just what I did.

Every few seconds, send out a MessagingService message that contains the player count. On the lobby game subscribe to this topic and get all player counts accordingly. Combine this with the datastore information to get a comprehensive list of all servers and relating information.

2 Likes

Hey I tried this and got kinda lost on getting on the GetPagesAsync part since I have no clue on what that is :sweat_smile:. Also could you kindly explain how that function works and wdym by static on getting the regular data store.

Static means values that dont change as the server progresses. For example, the maxium number of players never changes but the current player count does. If you dont know what GetSortedAsync is, its basically a function to get all the keys and values in a OrderedDataStore. You can read more here.

alr I tried using ur solution and it’s wonderful. But I got stuck on one thing tho, How do I send the player Lobby Info (which I made is a table) onto a global leaderboard since Ordered Data Store can’t send tables and while sending data by using Teleport Service is discouraged.

Edit:
I solved the issue on the main game side and how get the lobby Info when a player first teleports,

but the thing is I’m very confused on the lobby side of the game:

I got quite confused on this since I don’t have much experience when it first comes to data store, can you please give me like a sample code of how this works and give a detailed explanation?

I got confused on doing this, do I either send a GlobalAnnouncement or a specific key value. Im very confused, can you also explain this to me.

Also, I’m sorry if I dont respond quickly to this since Im going to sleep and its late in the night :sweat_smile: