So I honesty don’t know how to word this topic but I’ll try my best to explain.
I’m creating a game that will likely use “Messaging Service” to get a list of servers. Now here’s what I’m trying to achieve. I’m trying to get servers that are public but also allow for people to create private servers and/ or join them. The problem here is that I’m unclear as to how you would go about this entire system. Creating private servers and joining them, whilst the same for public servers.
Now here are a few questions I have:
Does Messaging Service get all types of servers?
Is it possible to manipulate how you can access a certain server? Allow for private servers to be join-able just by a click.
If you have any suggestions or go-abouts, It would be much appreciated. Thanks.
I also looked into the wiki and ect. There are some useful resources however, I have not found much that could possibly help. (Atleast not in my case)
So long as you have a main hub place with a custom in-game server list, you can store the reserved servers and if they’re marked as private then simply just don’t allow the user to teleport there.
With the reserved servers being listed on a UI in the main hub place, you can essentially make mock public & private servers.
MessagingService is unreliable. During my last test, only 20 out of 40 servers received messages I was sending. But yes, all servers are intended to receive messages from all other servers.
You cannot change the joinability of servers. There’s no way to access private player servers other than being invited by the owner.
You cannot create public servers, but you can create private servers using TeleportService:ReserveServer. This method will give you an access code and the private server ID of the created server.
Your best pick would be using DataStores to store server data. I use a regular DataStore to store server data and an OrderedDataStore to store the list, when polling I get the list first and then the data for each server.
Note that due to DataStore limits, this is not going to run well if you have > ~100 servers on your game. You should also integrate caching so the server list lookup doesn’t occur more than maybe twice a minute. If you want a more performant and robust service, you’ll have to make a custom server and use HttpService.
Lastly, you can also store the private server access codes received via ReserveServer in this list so that these private servers are also joinable.
Strange I thought DataStores aren’t ideal to use for this. I guess I could use DataStores in conjunction with messagingService.
It’s a bit of a shock with the first sentence you said. I think messaging service is most convenient and proves to be the go-to. I was thinking HTTP Service, but I heard it’s quite finicky to use and probably requires a lot more code.
DataStores do the job if you run < 100 servers, but they’re far from ideal for this purpose. Unless you write a script to automatically clean up expired server data like I did, you’ll have to live with the fact that you’re leaving tons of unnecessary data behind on Roblox’ database. Polling the list also requires one GetAsync request per server which can exhaust your request budget quickly.
HttpService itself does not require a lot of code, but you’ll have to script some server for the game servers to interact with. Writing a simple server to temporarily store and on request give a list of data is not hard to do with node.js either and eliminates the need for any permanent storage / database. You’ll also need an online server to run your app on, I recommend OVH for affordable well-performing linux VPS ($3.50/m for the “starter” plan iirc).
Yeh, well that’s why DataStores are far from ideal for the amount of servers being handled which will just lead to quick polling. However, the only issue I find with messagingservice is it’s a bit difficult to know which servers are alive or not, whilst managing it. I was thinking of using an web API to easily get the servers, as an alternative.
I’m not too experienced with this, but why exactly do you mean by an online server?
In order for all servers to pick up data from all other servers and manage a list, each server should publish their data at least twice a minute using MessagingService. Each server on its own tracks the activity of incoming data and for any server that hasn’t sent any data in so long (a minute, for example), it can be considered dead and the data can be dismissed / removed from the list.
If you’re going to use HttpService, you’ll need an interface to interact with. Some web server to send and retrieve the server data / list to and from. Said server (“app” refers to a process handling the http requests and server data) will have to be online 24/7. Unless you forward your ports (which can be a security risk in your home network!) and use a Raspberry Pi or some other computing device cheap on power, a VPS (virtual private server, so to say an always online computer reachable via IP) is your best choice to host this app.
Ahh, that makes a lot more sense now. I was thinking that using HTTP service requires just using the roblox site and getting all the servers which is clearly wrong. You need a web or external api to send a request. However, then how do you do it other way? To send a request to from in-game to a external source that returns the servers. Oh does that just work by sending request to an api and getting information about the server?
I get a bit confused, because I keep thinking the request needs to be sent and then sent back to the game? Thanks for the clarity
Well this would be a good time to use firebase realtime database. Well first of all we need some sort of poller which constantly does get request from firebase. Then we need a thing where when a server is created it’s JOBID get’s added to the firebase parent node. Lastly when BindToClose is called on a server which is reserved we need it to be removed from the parent node in firebase.
local RunService = game:GetService("RunService")
local GameInfo = require(game.ServerScriptService.Modules.GameInfo)
local IsStudio = RunService:IsStudio()
function SetServer(Value)
GameInfo.Firebase.ServerList:UpdateAsync("Servers", function(OldData)
if type(OldData) ~= 'table' then
OldData = {}
end
OldData[game.JobId] = Value
return OldData
end)
end
if IsStudio == true then -- studio server doesn't have a JOBID
print 'studio doesnt worl'
else
print(game.JobId, " this is the ID")
SetServer(true)
end
game:BindToClose(function()
if IsStudio == true then
print 'p'
else
-- you have to remove the node from "servers'
GameInfo.Firebase.ServerList:DeleteAsync("Servers/".. game.JobId)
end
end)
while true do -- poller
local Data = GameInfo.Firebase.ServerList:GetAsync("Servers")
for ServerName,PlaceHolderValue in pairs(Data) do
print(ServerName)
end
wait(30) -- 30 second server update rate
end
ANYWAYS Good thing universe scripts and temporary datastores are coming, then we can do this without the 50,000 read limit in firebase for the free plan. Sure you can buy the paid plan if you want though.
When universe scripts come this will be practical until now we’ll have to rely on buying other databases and using it. (50,000 read limit isn’t big enough for big games), that’s why we need the paid plan.
BUT YOU CAN MAKE A JOIN PERSON SYSTEM, THAT IS PRACTICAL TO DO.
All requests would be made by Roblox game servers. Frequent requests (twice a minute) of type A would be done to send information about the game server (Job ID, etc) to the app and separate requests of type B can be used to poll the server list from the app. One could of course have the server list be returned as a response to request type A, but doing so would just create unnecessary traffic.
takes the whole work of writing a server app off your shoulders, a nice solution for beginners. However, as 0Shank also stated, the 20k daily request limits are very tight and impractical for large games.
These will probably be the best solutions but do unfortunately not exist yet.
I’ll see what I can do, and I’ll experiment with the provided suggestions.
Honeslty lookin back on it, I don’t even know why I wanted to have private servers that were public, smh.