• Screen Loading Help...
    8 replies, posted
Don't tell me to use search button I was looking for 1-2 hours then 4 hours on google! How do I display someones name, SteamID and Golden Forge Scrap? Like when they Connect it show's their Steam Name, SteamID and Scrap Please help (Not sure if this is right Place!)
This is what I use, requesting their details via the Steam API (PHP) : [code] <?php //Helper functions function get_data($url) { //get data from a url $ch = curl_init(); $timeout = 5; $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //End of helpers //Get data from the url $MapName = isset($_GET['mapname']) ? $_GET['mapname'] : false; $Steam64 = isset($_GET['steamid']) ? $_GET['steamid'] : false; if ($Steam64 == false) { $USERNAME = 'DEBUG'; $USERIMG = 'noavatar.jpg'; $USERSTEAM = "NO_STEAM_ID?"; } else { //we have a 64bit id, lookup their profile to get their name $APIKey = "YOUR_APIKEY_GOES_HERE"; $APIUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$APIKey}&steamids={$Steam64}"; $jsonResponse = get_data($APIUrl); $Result = json_decode($jsonResponse); $Info = $Result->response->players[0]; $USERNAME = $Info->personaname; $USERIMG = $Info->avatarmedium; //do some math to get their nice steam_id $authserver = bcsub($Steam64, '76561197960265728') & 1; $authid = (bcsub($Steam64, '76561197960265728')-$authserver)/2; $USERSTEAM = "STEAM_0:{$authserver}:{$authid}"; } ?> [/code] You can now use $USERNAME, $USERSTEAM and $USERIMG wherever you need to. I just echo them in the HTML. [code] <div style="width:620px; margin: 0 auto; margin-top:10px; overflow: show; background-color:rgba(18,52,86,0.5); border:2px solid black; border-radius:12px;"> <div style="overflow:auto; color: #abcdef; font-weight: bold; text-shadow: #123456 0px 0px 2px;"> <div style="float:left;margin-left:100px;padding:5px;"> <img src="<?php echo $USERIMG; ?>" style="wdth:64px;height:64px;border-radius:5px;border:3px solid white;box-shadow:0 0 5px #000;" /> </div> <div style="width:70%;float:right;padding-top:25px;text-align:left;"> Hello <span style="color:red;"><?php echo $USERNAME; ?></span><br /> Your steam id is <span style="color:orange;"><?php echo $USERSTEAM; ?></span> </div> </div> </div> [/code] You need to replace YOUR_APIKEY_GOES_HERE with a key you get when you register for the steam API access [url]http://steamcommunity.com/dev[/url] Although the styling is specific to my loading screen, this will get you working with showing their avatar, username and steamid. You should take a look at all the information you can get from the API [url]http://steamcommunity.com/dev[/url] --------------------------- I'll try to explain exactly what this does: [code]$APIKey = "YOUR_APIKEY_GOES_HERE"; $APIUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$APIKey}&steamids={$Steam64}"; $jsonResponse = get_data($APIUrl); $Result = json_decode($jsonResponse);[/code]This builds a request to send to the steam API, and gets a response. It then parses the response into an object using json_decode. [code]$Info = $Result->response->players[0];[/code]This gets the actual info out of the response object. What $Info contains is listed here [url]https://developer.valvesoftware.com/wiki/Steam_Web_API#Public_Data[/url] [code]$USERNAME = $Info->personaname; $USERIMG = $Info->avatarmedium;[/code]Get the info we want out of our $Info object. [code]//do some math to get their nice steam_id $authserver = bcsub($Steam64, '76561197960265728') & 1; $authid = (bcsub($Steam64, '76561197960265728')-$authserver)/2; $USERSTEAM = "STEAM_0:{$authserver}:{$authid}";[/code]This is how you normally get their steamid. I don't actually need to this because $Info has their steamid already, but I left it like this. ------ Instead of registering for the steam API, you can also load a public xml file with the info, but either way is just as good, depending on the server you run it on (some servers won't let you use Curl which I use here). ANOTHER EDIT: I just realised you also asked for Golden Forge Scrap. I'm not sure exactly what that is, sorry.
That script doesn't work for me all it pop up with lotsa writing :<
[QUOTE=meggerman99;39687322]That script doesn't work for me all it pop up with lotsa writing :<[/QUOTE] It is PHP code so you need to be sure it is inside a .php file on a webserver that can run it. And the HTML snippet is only for a box showing their details, you should include it inside a properly formatted page. EDIT: Sorry, I realised I left off the first <?php , it has a better chance of working with copy-paste now.
[QUOTE=wh1t3rabbit;39687423]It is PHP code so you need to be sure it is inside a .php file on a webserver that can run it. And the HTML snippet is only for a box showing their details, you should include it inside a properly formatted page.[/QUOTE] it is Test3.php But Idk were all code is or if it is just seperate things
[QUOTE=meggerman99;39687430]But Idk were all code is or if it is just seperate things[/QUOTE] If you copy the first two blocks of code, the php for requesting it, and html for displaying, and put them together, it should display now (but will probably not be lined up right). To have it work ingame you need to modify your loading url to append the steamid to it. Say your loading url is currently set like this sv_loadingurl "http://www.example.com/Test3.php" You need to change it to be like sv_loadingurl "http://www.example.com/Test3.php?steamid=%s"
For some reason the player avatar does not show for me and I get: Hello DEBUG Your steam id is NO_STEAM_ID? CODE here: [url]http://paste.ubuntu.com/6439775/[/url]
[QUOTE=Judd;42905654]For some reason the player avatar does not show for me and I get: Hello DEBUG Your steam id is NO_STEAM_ID? URL here: [url]http://paste.ubuntu.com/6439775/[/url][/QUOTE] You had a working url before your edit. You just needed to add ?steamid=%s on the end of it
got it working!
Sorry, you need to Log In to post a reply to this thread.