ID:2643050
 
(See the best response by Nadrew.)
Hello,

I’m not sure if this is the right section for this. But, I was wondering if it was possible to detect if other servers are live on the hub and have the player connect? Whether through a prompt or automatically.

For example;
A player clicks the .exe file to play the game
When the game loads, it checks if there are any live servers on the game hub(assuming there’s servers that are live)
If there is, prompt the player to connect to the server.

Hopefully my question was explained well enough. Thanks guys!
Best response
You could parse the ?format=text version of the hub entry.

Example:
http://www.byond.com/games/Exadv1/SpaceStation13?format=text

If you're using BYONDexe, it already provides javascript stuff to get this information, all documented in the readme.
In response to Nadrew
Well, I got it partly figured out.
proc/ServerDetection()
var/http[] = world.Export("http://www.byond.com/games/Exadv1/SpaceStation13?format=text")
if(!http)
return
var/C = http["CONTENT"]
if(C)
var/Content = file2text(C)
if(!findtext(Content,"url"))
return
else
var/server = findtext(Content,"url")
//var/Listy = file2text(server)
world << output("[server]", "Login.output")


While I can get hub info, I'm having issues narrowing it down to just the server address links.
The text format is actually the same format as a savefile, so if you're doing this in DM, you can use ImportText() to turn it into a nice friendly savefile structure.