Garry's Mod

Garry's Mod

Not enough ratings
GMod Loading Screen - Map name and Steam ID
By Uber Build
I will be showing how to display steam ID's and map names using HTML and Garrys Mod. This is a way of showing how to do this with the information shown on the Garrys Mod wiki in an easier to follow way.
   
Award
Favorite
Favorited
Unfavorite
What you will need
What you will need:
  • Basic HTML / CSS / PHP understanding.
  • Hosting for the PHP document.
  • A Garrys Mod Server.
  • A text editor for HTML, PHP and CSS.
  • File transfer access to your server.
Creating the document
First off we need a document what you will make the loading screen in if you have not got one.

To do this firstly make a folder where you will be working on your loading screen and create a new text document. Secondly rename the document so it becomes a PHP document by removing the on the end of the name and adding in .php. (Example: index.php, loading.php, screen.php)

After you have created the document open it up with a text editor. You can use Notepad but it is highly reccommended to download a designed editor such as Notepad ++.
After you have created your PHP document move on to step 2.
Getting the community ID and map name
First up we need to create the basic HTML lay out:






Secondly in the head we need to define the community ID and map name variables using PHP.
First open the PHP tags using
<?php
?>







Next using PHP we are going to make two variables using the "$" sign.
Also with the variables we are going to set them using $_GET[];

For the community id we will use:
$communityid = $_GET[user];
$mapname = $_GET[mapname];





Remember what you included in the [ ] brackets as we will be needing it later.
After you have completed this we have gotten the community ID off the player and the map name off the server as variables.
Getting the users Steam ID
This is by far the hardest part of the guide and I recommend if you have limited PHP experience you copy and paste this part in and DO NOT touch any of it.

Firstly we must get the auth servers for the players Steam ID. To do this use the following PHP line:
$authserver = bcsub( $communityid, '76561197960265728' ) & 1;
Second we must get the authid of the player which is the main part of the players steam ID.
For this we must use the following line which gets the first number of the players Steam ID which will be used later.

$authid = (bcsub( $communityid, '76561197960265728' ) - $authservers ) / 2;

Then we must combine the authserver together to create the players steam ID.

$steamid = "STEAM_0:$authserver:$authid";

Remember PHP requires that each of the lines has a semicolon (;) after them or else your loading screen will return errors

After you have completed this your loading screen should look like:

Printing out the steam ID and Map Name
This is the easiest section of the guide.

Now we will go to the body section of the HTML document to make the document more oraganised.
Insert your <?php ?> tags in the the <body></body> section of the document and complete the rest of this section.


Next we will be simply printing out the steam ID and map name.

To do this we will the be using the "echo" function in PHP.

Firstly we will print out the map that the server is currently running on.]

To do this we will use
echo "$mapname";
Make sure you use the variable you set before.
To add more style to this you can also add text into the echo function such as:

echo "The server is currently on the map: $mapname";

The same principle also goes for the steamID of the player.
It can be done using
echo "$steamid";

Also to create new lines using echo simply add in <br>

Example:
echo "Welcome to our server $steamid !<br>The server is currently on $mapname<br>Have a good time!";


Conclusion
Part of this guide was made thanks to help from the Garrys Mod Wiki on loading screens:
http://wiki.garrysmod.com/page/Loading_URL

To add this page to your server simply have it available on a webhost and in your server.cfg file add in
sv_loadingurl "url".

In your URL you MUST add this behind the loading url:

?mapname=%m&steamid=%s
^ Note this line has been changed and was written wrong.

(Unless you edi the PHP you must use this line in sv_loadingurl)

Example:
sv_loadingurl "http://rubergaming.site.nfoservers.com/test/loading.php?mapname=%m&steamid=%s"
22 Comments
santyvulla 6 Jul, 2019 @ 2:27am 
thx
Justin 26 Sep, 2017 @ 1:23am 
What you will need:
*Basic HTML / CSS / PHP understanding. *
Hosting for the PHP document.
A Garrys Mod Server.
A text editor for HTML, PHP and CSS.
File transfer access to your server.

So if you don't know HTML, CSS, or PHP, get someone else to do it for you, go to gmodstore, put a little bit of money into your server and pay someone like $10 or $5 for a custom loading screen, or learn it before coming to the comments complaining about your incompetence to make a loading screen

Thanks
Erdling 2 Mar, 2017 @ 7:46am 
Thanks!
[Fr]Nyhu 26 Aug, 2016 @ 9:13am 
whit api, can we tack the current player number who are on the server ? I search a way to make retrun this number on a php file...
NOP 21 Aug, 2016 @ 5:49am 
I play with variables and I found out that $communityid and $authid - nothing, $authserver - -38280598980132864. xD Why is that?
NOP 21 Aug, 2016 @ 5:42am 
I have a problem. I do everything as written here, but I did get this: STEAM_0:0:-38280598980132864 :yawning_creep:
Stubbo 20 Jun, 2016 @ 4:20am 
don't know if you guys actually know much but php code needs to be a php file
KenOkarun 13 May, 2016 @ 7:39pm 
Kinda new into these stuff, and I'm interested.
Do i need to embed the code to HTML?
(I'm using 000webhost and i think its better than other site builders that wont support php)
nat 3 Aug, 2015 @ 8:52am 
yaya1711 17 Jul, 2015 @ 10:32am 
is the steam id supposed to be getting the player's steam id? because if it is its not working
and does anyone know how to get the player's username?