Hello. How would I be able to code my loading screen to display the current map, and say something such as; "Welcome (Playername)! Enjoy your stay!"
Thanks in advance.
[url=http://lmgtfy.com/?q=gmod+loading+screen+show+map+and+player+name]Let me Google that for you[/url].
[highlight](User was banned for this post ("Let me Google that for you." - Gran PC))[/highlight]
[QUOTE=Xanavolt;41248465][url=http://lmgtfy.com/?q=gmod+loading+screen+show+map+and+player+name]Let me Google that for you[/url].[/QUOTE]
Hm. I copied the code on the wiki, but it doesn't display my community ID, or the map properly... Not sure what function I'd use for a players name? playername?
Edit: Looked on the wiki... couldn't find it.. Tried
playername
playernick
player.nick
Copy and paste the code in to a post.
[QUOTE=E.N.I.G.M.A;41249323]Copy and paste the code in to a post.[/QUOTE]
[code]<?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!";
?>[/code]
Once again reposting an old tutorial i made a long time ago:
[quote]
1. We're going to use the Steam Web API for this, so first you have to get a key. Get One here: [url]http://steamcommunity.com/dev/apikey[/url]
2. now that we have this, heres an example of what a php file could look like:
[html]
<html>
<body>
<?php
$id = $_GET["steamid"];
$map = $_GET["mapname"];
$link = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=INSERT WEB API KEY HERE&steamids=' . $id . '&format=json');
$myarray = json_decode($link, true);
?>
<!-- prints the avatar -->
<img class="avatar" src="<?php print $myarray['response']['players'][0]['avatarmedium']; ?>" />
<!-- prints there nickname -->
<p class="name"><?php print $myarray['response']['players'][0]['personaname']; ?></p>
</body>
</html>
[/html]
Make sure you put your web api key where i said to put it in the PHP.
Also make sure to put %s and %m in the link to the php file
[/quote]
[QUOTE=ben434;41255110]Once again reposting an old tutorial i made a long time ago:[/QUOTE]
Will try this after my league game. :)
[editline]1st July 2013[/editline]
[QUOTE=ben434;41255110]Once again reposting an old tutorial i made a long time ago:[/QUOTE]
Nothing seems to display on my loading screen when using that code.
[QUOTE=PrevailGFX;41257647]
Nothing seems to display on my loading screen when using that code.[/QUOTE]
Did you put your web api key in the file_get_contents() function? Did you use [url]www.example.com/loadingscreen.php%s%m[/url] in your sv_loadingurl?
[QUOTE=ben434;41259149]Did you put your web api key in the file_get_contents() function? Did you use [url]www.example.com/loadingscreen.php%s%m[/url] in your sv_loadingurl?[/QUOTE]
Yes I did.
[QUOTE=PrevailGFX;41261698]Yes I did.[/QUOTE]
Show me your file_get_contents function.
[editline]a[/editline]
I just tested the script and it works fine
[img_thumb]http://i.imgur.com/qnvhNUi.png[/img_thumb]
[QUOTE=ben434;41261941]Show me your file_get_contents function.
[editline]a[/editline]
I just tested the script and it works fine
[img_thumb]http://i.imgur.com/qnvhNUi.png[/img_thumb][/QUOTE]
PM'ing
[QUOTE=PrevailGFX;41262251]PM'ing[/QUOTE]
Ok, I got your pm. Everything seems correct, perhaps the place you are hosting it doesn't have php? I have to use 000webhost (shitty free service, but no ads) to get the php working correctly. Try using 000webhost or others that have php installed and see if that works.
[QUOTE=ben434;41262336]Ok, I got your pm. Everything seems correct, perhaps the place you are hosting it doesn't have php? I have to use 000webhost (shitty free service, but no ads) to get the php working correctly. Try using 000webhost or others that have php installed and see if that works.[/QUOTE]
I'm indeed using 000webhost already. :)
I'll send you a picture of my html? One sec.
OP, this might be of use to you.
[code]
<?php
/*
* Copyright 2010 Rob McFadzean <rob.mcfadzean@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
class SteamAPIException extends Exception { }
class SteamAPI {
private $customURL;
private $steamID64;
private $gameList;
function version() {
return (float) '0.1';
}
/**
* Sets the $steamID64 or CustomURL then retrieves the profile.
* @param int $id
* */
function __construct($id) {
if(is_numeric($id)) {
$this->steamID64 = $id;
} else {
$this->customURL = strtolower($id);
}
$this->retrieveProfile();
}
/**
* Creates and then returns the url to the profiles.
* @return string
* */
function baseUrl() {
if(empty($this->customURL)) {
return "http://steamcommunity.com/profiles/{$this->steamID64}";
}
else {
return "http://steamcommunity.com/id/{$this->customURL}";
}
}
/**
* Retrieves all of the games owned by the user
* */
function retrieveGames() {
$url = $this->baseUrl() . "/games?xml=1";
$gameData = new SimpleXMLElement(file_get_contents($url));
$this->gamesList = array();
if(!empty($gameData->error)) {
#throw new SteamAPIException((string) $gameData->error);
}
foreach($gameData->games->game as $game) {
$g['appID'] = (string) $game->appID;
$g['name'] = (string) $game->name;
$g['logo'] = (string) $game->logo;
$g['storeLink'] = (string) $game->storeLink;
$g['hoursOnRecord'] = (float) $game->hoursOnRecord;
$g['hoursLast2Weeks'] = (float) $game->hoursLast2Weeks;
$this->gameList[] = $g;
#print_r($this->gameList);
}
}
/**
* Retrieves all of the information found on the profile.
* */
function retrieveProfile() {
$url = $this->baseUrl() . "/?xml=1";
$profileData = new SimpleXMLElement(file_get_contents($url));
if(!empty($profileData->error)) {
#throw new SteamAPIException((string) $profileData->error);
}
$this->steamID64= (string) $profileData->steamID64;
$this->friendlyName = (string) $profileData->steamID;
$this->onlineState = (string) $profileData->onlineState;
$this->stateMessage = (string) $profileData->stateMessage;
$this->privacyState = (string) $profileData->privacyState;
$this->visibilityState = (int) $profileData->visibilityState;
$this->avatarIcon = (string) $profileData->avatarIcon;
$this->avatarMedium = (string) $profileData->avatarMedium;
$this->avatarFull = (string) $profileData->avatarFull;
$this->vacBanned = (bool) $profileData->vacBanned;
if($this->privacyState == "public") {
$this->customUrl = strtolower((string) $profileData->customURL);
$this->memberSince = (string) $profileData->memberSince;
$this->steamRating = (float) $profileData->steamRating;
$this->location = (string) $profileData->location;
$this->realName = (string) $profileData->realname;
$this->hoursPlayed2Wk = (float) $profileData->hoursPlayed2Wk;
$this->favoriteGame = (string) $profileData->favoriteGame->name;
$this->favoriteGameHoursPlayed2Wk = (string) $profileData->favoriteGame->hoursPlayed2wk;
$this->headLine = (string) $profileData->headline;
$this->summary = (string) $profileData->summary;
}
if(!empty($profileData->weblinks)) {
foreach($profileData->weblinks->weblink as $link) {
$this->weblinks[(string) $link->title] = (string) $link->link;
}
}
}
/**
* If there are no games in the variable it calls the retrieveGames() function, upon completion returns an array of all of the owned games and related information
* @return array
* */
function getGames() {
if(empty($this->gameList)) {
$this->retrieveGames();
}
return $this->gameList;
}
/**
* Returns the friendly name of the user. The one seen by all friends & visitors.
* @return string
* */
function getFriendlyName() {
return $this->friendlyName;
}
/**
* Returns the users current state. (online,offline)
* @return string
* */
function onlineState() {
return $this->onlineState;
}
/**
* Returns the state message of the user (EG: "Last Online: 2 hrs, 24 mins ago", "In Game <br /> Team Fortress 2")
* @return string
* */
function getStateMessage() {
return $this->stateMessage;
}
/**
* Returns the users Vac status. 0 = Clear, 1 = Banned
* @return boolean
* */
function isBanned() {
return $this->vacBanned;
}
/**
* Returns a link to the small sized avatar of the user (32x32)
* @return string
* */
function getAvatarSmall() {
return $this->avatarIcon;
}
/**
* Returns a link to the medium sized avatar of the user (64x64)
* @return string
* */
function getAvatarMedium() {
return $this->avatarMedium;
}
/**
* Returns a link to the full sized avatar of the user
* @return string
* */
function getAvatarFull() {
return $this->avatarLarge;
}
/**
* Returns the Steam ID of the user
* @return int
* */
function getSteamID64() {
return $this->steamID64;
}
/**
* Returns the total amount of games owned by the user
* @return int
* */
function getTotalGames() {
return sizeof($this->gameList);
}
}
?>
[/code]
[QUOTE=MONGLER;41268048]OP, this might be of use to you.
[code]
<?php
/*
* Copyright 2010 Rob McFadzean <rob.mcfadzean@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
class SteamAPIException extends Exception { }
class SteamAPI {
private $customURL;
private $steamID64;
private $gameList;
function version() {
return (float) '0.1';
}
/**
* Sets the $steamID64 or CustomURL then retrieves the profile.
* @param int $id
* */
function __construct($id) {
if(is_numeric($id)) {
$this->steamID64 = $id;
} else {
$this->customURL = strtolower($id);
}
$this->retrieveProfile();
}
/**
* Creates and then returns the url to the profiles.
* @return string
* */
function baseUrl() {
if(empty($this->customURL)) {
return "http://steamcommunity.com/profiles/{$this->steamID64}";
}
else {
return "http://steamcommunity.com/id/{$this->customURL}";
}
}
/**
* Retrieves all of the games owned by the user
* */
function retrieveGames() {
$url = $this->baseUrl() . "/games?xml=1";
$gameData = new SimpleXMLElement(file_get_contents($url));
$this->gamesList = array();
if(!empty($gameData->error)) {
#throw new SteamAPIException((string) $gameData->error);
}
foreach($gameData->games->game as $game) {
$g['appID'] = (string) $game->appID;
$g['name'] = (string) $game->name;
$g['logo'] = (string) $game->logo;
$g['storeLink'] = (string) $game->storeLink;
$g['hoursOnRecord'] = (float) $game->hoursOnRecord;
$g['hoursLast2Weeks'] = (float) $game->hoursLast2Weeks;
$this->gameList[] = $g;
#print_r($this->gameList);
}
}
/**
* Retrieves all of the information found on the profile.
* */
function retrieveProfile() {
$url = $this->baseUrl() . "/?xml=1";
$profileData = new SimpleXMLElement(file_get_contents($url));
if(!empty($profileData->error)) {
#throw new SteamAPIException((string) $profileData->error);
}
$this->steamID64= (string) $profileData->steamID64;
$this->friendlyName = (string) $profileData->steamID;
$this->onlineState = (string) $profileData->onlineState;
$this->stateMessage = (string) $profileData->stateMessage;
$this->privacyState = (string) $profileData->privacyState;
$this->visibilityState = (int) $profileData->visibilityState;
$this->avatarIcon = (string) $profileData->avatarIcon;
$this->avatarMedium = (string) $profileData->avatarMedium;
$this->avatarFull = (string) $profileData->avatarFull;
$this->vacBanned = (bool) $profileData->vacBanned;
if($this->privacyState == "public") {
$this->customUrl = strtolower((string) $profileData->customURL);
$this->memberSince = (string) $profileData->memberSince;
$this->steamRating = (float) $profileData->steamRating;
$this->location = (string) $profileData->location;
$this->realName = (string) $profileData->realname;
$this->hoursPlayed2Wk = (float) $profileData->hoursPlayed2Wk;
$this->favoriteGame = (string) $profileData->favoriteGame->name;
$this->favoriteGameHoursPlayed2Wk = (string) $profileData->favoriteGame->hoursPlayed2wk;
$this->headLine = (string) $profileData->headline;
$this->summary = (string) $profileData->summary;
}
if(!empty($profileData->weblinks)) {
foreach($profileData->weblinks->weblink as $link) {
$this->weblinks[(string) $link->title] = (string) $link->link;
}
}
}
/**
* If there are no games in the variable it calls the retrieveGames() function, upon completion returns an array of all of the owned games and related information
* @return array
* */
function getGames() {
if(empty($this->gameList)) {
$this->retrieveGames();
}
return $this->gameList;
}
/**
* Returns the friendly name of the user. The one seen by all friends & visitors.
* @return string
* */
function getFriendlyName() {
return $this->friendlyName;
}
/**
* Returns the users current state. (online,offline)
* @return string
* */
function onlineState() {
return $this->onlineState;
}
/**
* Returns the state message of the user (EG: "Last Online: 2 hrs, 24 mins ago", "In Game <br /> Team Fortress 2")
* @return string
* */
function getStateMessage() {
return $this->stateMessage;
}
/**
* Returns the users Vac status. 0 = Clear, 1 = Banned
* @return boolean
* */
function isBanned() {
return $this->vacBanned;
}
/**
* Returns a link to the small sized avatar of the user (32x32)
* @return string
* */
function getAvatarSmall() {
return $this->avatarIcon;
}
/**
* Returns a link to the medium sized avatar of the user (64x64)
* @return string
* */
function getAvatarMedium() {
return $this->avatarMedium;
}
/**
* Returns a link to the full sized avatar of the user
* @return string
* */
function getAvatarFull() {
return $this->avatarLarge;
}
/**
* Returns the Steam ID of the user
* @return int
* */
function getSteamID64() {
return $this->steamID64;
}
/**
* Returns the total amount of games owned by the user
* @return int
* */
function getTotalGames() {
return sizeof($this->gameList);
}
}
?>
[/code][/QUOTE]
Dunno If I'm doing something wrong or what, but when I paste that in, nothing shows... still
[QUOTE=PrevailGFX;41270471]Dunno If I'm doing something wrong or what, but when I paste that in, nothing shows... still[/QUOTE]
Your not calling the functions any where, so you won't display anything. I would stick with ben434 php code looks a lot easier to understand. Give us a link to the site that your hosting ben434 code on.
I'm going to go ahead and ask the obvious:
Do you have PHP installed and enabled on your web server?
[QUOTE=YoshieMaster;41294245]I'm going to go ahead and ask the obvious:
Do you have PHP installed and enabled on your web server?[/QUOTE]
He said he already uses 000webhost, which has php.
[QUOTE=PrevailGFX;41248226]Hello. How would I be able to code my loading screen to display the current map, and say something such as; "Welcome (Playername)! Enjoy your stay!"
Thanks in advance.[/QUOTE]
You may want to take a look at the wiki
[URL]http://wiki.garrysmod.com/page/Loading_URL[/URL]
[QUOTE=ben434;41259149]* non related-stuff* Did you use [url]www.example.com/loadingscreen.php%s%m[/url] in your sv_loadingurl?[/QUOTE]
it should be
[url]http://aurlhere.com/file.php?steamid=%s[/url]
[B]?steamid=%s[/B]
your not assigning the steamid to a variable in the get command
[QUOTE=E.N.I.G.M.A;41277618]Your not calling the functions any where, so you won't display anything. I would stick with ben434 php code looks a lot easier to understand. Give us a link to the site that your hosting ben434 code on.[/QUOTE]
[url]http://waynesttt.net76.net/LoadingScreen.php[/url]
[editline]4th July 2013[/editline]
"sv_loadingurl" "http://waynesttt.net76.net/loadingscreen.php?steamid=%s"
"sv_loadingurl" "http://www.waynesttt.net76.net/loadingscreen.php%s%m"
Both 404 when loading.
Why don't you post the code here so we can help you?
[QUOTE=PrevailGFX;41308183][url]http://waynesttt.net76.net/LoadingScreen.php[/url]
[editline]4th July 2013[/editline]
"sv_loadingurl" "http://waynesttt.net76.net/loadingscreen.php?steamid=%s"
"sv_loadingurl" "http://www.waynesttt.net76.net/loadingscreen.php%s%m"
Both 404 when loading.[/QUOTE]
You get 404 becouse the URL is wrong. Its [url]http://waynesttt.net76.net/LoadingScreen.php?steamid=%s[/url]
[url]http://waynesttt.net76.net/LoadingScreen.php?steamid=76561198031633135[/url] That works, you just need to style the page properly, you will need to replace the comunityid with %s like all the other posts
I suppose you got the idea from my loading screen? :v:
[url]http://urbangamers.net/loading/[/url]
[QUOTE=munch;41315792]I suppose you got the idea from my loading screen? :v:
[url]http://urbangamers.net/loading/[/url][/QUOTE]
Uhhh... Idk what you're talking about...
[url]http://i.imgur.com/Vp1jYbU.png[/url]
I'll change it if you want... I can do Photoshop, I'm just not creative.
Edit: Fuck this. It just won't display their avatar or name.
[QUOTE=PrevailGFX;41323855]Uhhh... Idk what you're talking about...
[url]http://i.imgur.com/Vp1jYbU.png[/url]
I'll change it if you want... I can do Photoshop, I'm just not creative.
Edit: Fuck this. It just won't display their avatar or name.[/QUOTE]
Do you read the other posts?
[QUOTE=TRURASCALZ;41315666][url]http://waynesttt.net76.net/LoadingScreen.php?steamid=76561198031633135[/url] That works, you just need to style the page properly, you will need to replace the comunityid with %s like all the other posts[/QUOTE]
It was displaying the avatar and the name.
[QUOTE=munch;41315792]I suppose you got the idea from my loading screen? :v:
[url]http://urbangamers.net/loading/[/url][/QUOTE]
[URL="http://www.alessioatzeni.com/wp-content/tutorials/html-css/CSS3-loading-animation-loop/index.html"]Yeah, he did.[/URL]
[QUOTE=E.N.I.G.M.A;41325251]Do you read the other posts?
It was displaying the avatar and the name.[/QUOTE]
Yeah, I had it working... but then I tried to add <ap div> tags to it, and I broke it... I couldn't fix it. :\
[QUOTE=PrevailGFX;41326155]Yeah, I had it working... but then I tried to add <ap div> tags to it, and I broke it... I couldn't fix it. :\[/QUOTE]
I would recommend you learn php and html if you don't all ready know them. Post your code again so we can help you.
Sorry, you need to Log In to post a reply to this thread.