Sv loadingurl

From GMod Wiki

Jump to: navigation, search
Console.png Go to:
Console Variables
Server Variable
CVar:sv_loadingurl
Description:The page players will see when joining your server and downloading resources.
Gamemode:All
Default Value:http://loading.garrysmod.com


Setting up a sv_loadingurl page

To setup sv_loadingurl all you need is a web server to host the page on. Once you have uploaded your page just run sv_loadingurl "http://mywebsite.com/loadingurl" or whatever the directory name (or php file) is.

Webpage Javascript functions

These are the javascript functions that the game will call to your webpage to update the status of the joining process. You can see an implementation of it at http://loading.garrysmod.com

To use these javascript functions simply define them in your HTML with the exact name and number of parameters as are shown in the above list. GMod will call them as the information updates.

Using PHP with Loading URL

If you run sv_loadingurl "http://mywebsite.com/loadingpage.php?steamid=%s&mapname=%m" then the following $_GET values are available to PHP.

Example code for a simple loading page.

<?php
//Get the steamid (really the community id)
$communityid = $_GET["steamid"];
//Get the map name
$mapname = $_GET["mapname"];
//See if the second number in the steamid (the auth server) is 0 or 1. Odd is 1, even is 0
$authserver = bcsub($communityid, '76561197960265728') & 1;
//Get the third number of the steamid
$authid = (bcsub($communityid, '76561197960265728')-$authserver)/2;
//Concatenate the STEAM_ prefix and the first number, which is always 0, as well as colons with the other two numbers
$steamid = "STEAM_0:$authserver:$authid";

//Output welcome line
echo "Welcome to my server!<br>";
//Output Steam Community ID
echo "Your Community ID is $communityid<br>";
//Output calculated SteamID
echo "Your SteamID is $steamid<br>";
//Output current map
echo "The current map is $mapname<br>";
//Output friendly greeting
echo "Enjoy your stay!";
?>

This will output something similar to

Welcome to my server!
Your CommunityID is 76561197962734862
Your SteamID is STEAM_0:0:1234567
The current map is gm_construct
Enjoy your stay!

NOTE: You must have bcmath installed and use bcsub where shown for PHP to be able to correctly calculate a player's SteamID from their Community ID


Extra Information: "sv_loadingurl" does not work just inside of server.cfg, it needs to be in the command line and autoexec.cfg to work properly

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox