Open ghost opened 10 years ago
I support having the current javascript values available via the URL/get as well. But I'd also like to see the player's display name and avatar URL accessible (in both javascript and URL) too. This would speed up loading screens and reduce web server load as most loading screens using the Steam API are just grabbing the avatar and name.
I'm working on a loading screen at the moment and want to access the avatar and player display name. It'd be really useful if that information was provided via the URL and the "GameDetails" javascript function. Any chance it could make it into the next Gmod update?
I'd prefer to have them available via POST. GET (URL parameters) need special encoding and decoding, are limited by the maximum size a URL can be and generally look ugly.
For the player name and avatar: use the steamid, that's all you need, use the steam api to query the rest of the data, I'd prefer it if the steamid would be a 64 Bit integer instead of a string though as that's easier to pass to the steam api and avoids possible clashes in parsing...
Adding support for game servers with steam id's is also something that can be considered to be passed along, possibly reducing the amount of paramenters that need to be passed.
The issue with the API is that you can't use it clientside because AFAIK it's forbidden to share the API key. That means if you want to show the avatar/name you can't have a pure clientside-only loading screen. POST has the same issue. That's why I think the avatar and name should be available (without having to use the API) and the data should be available both serverside (either via GET or POST) and clientside (either via GET/URL parameters or javascript) to cover the different ways it'd be used. As you've said, having too much data via the URL isn't great. So having POST (for serverside) and javascript (for clientside) would be the best combination in my opinion.
Remember that every website is serverside at first.
I use a simple PHP script as loading screen backend and still handle the info that gmod sends via JS. The key is to use AJAX for requesting the data from a PHP script and then parse that (that way only the php part knows about the api key...)
It'd be impossible to put all of the info into GET parameters or make it available "instantly".
Well but most of it is available even before the website is being called no? Listing those and seeing which information is most important to have early could make things easier.
I always thought that it's strange that most information's are received so late that it isn't even able to get displayed as loading times tend to be fast nowadays.
Can the loading screen access Awesomium's asset:// files like the game menu does? Maybe for clientside, devs could refer to an asset:// javascript file and Gmod would have that file contain the values (server ip/gamemode/map and player name/avatar/id etc) and call the function that indicates they're ready. It'd need to be controlled by the engine rather than being an actual file but that would solve it clientside.
They can load files with the asset scheme. Including a little helper file with common functions could be cool.
For you having problems with the steam API, you could try to use this: http://pastebin.com/tsAQ5bki it works faster than the steam API for me.
the xml profile is deprecated and will be removed somewhere in the future
But while it works its better to use it, you can add a check to see if it still works, and leave the steam API as a fallback.
My idea to pass the information:
The global Javascript object could be easily injected like this:
<body>
with something like
<script>garrysmodGlobalData = JSON.parse( {the data from the game here} )</script>
<body>
So we can easily use it to display it and also process it.
I would add the players playing rn on the server to the parameters
Currently, only the server name, server url, map name, max players, steam id and gamemode are given to the loading page. Of those parameters, only the map name and steam id are sent to the page, and the rest can be found via GameDetails in JS.
I think that all of those parameters should be replaced into the URL at the start, so they can be processed server-side, and so that they can be found right at the start (GameDetails is only sent when all assets have finished downloading)
Also, there could be a few more parameters added, such as:
Finally, there should be a method like GameDetails with the same data, but called at right at the start of page load. I assume all the data is already available by the time you've found out what files to download/map to load, so I don't understand why GameDetails has to be delayed until all the assets download.
So, 3 improvements I think Garry's Mod loading screens would benefit from:
I also made a thread about it on the forums: http://facepunch.com/showthread.php?t=1316418