Priceless Posted May 3, 2013 Share Posted May 3, 2013 Well hai there! I have been strugling to find a way to translate steamid from string into a community page url. steamid = $_POST['steamid']; next I need to remove the STEAM_0: <-- part of the string so its left with either 0: or 1: + the rest of the steamid now I need to multply the part that is (after STEAM_0:1or0:) (example STEAM_0:1:123456 * 2) with 2 obviously. now if it was STEAM_0:1 (aka 1) you have to add the multplied subject above (example 123456 * 2 + 1) or (example 123456 * 2 + 0) depending if there is STEAM_0:1 or STEAM_0:0 then I need to add the result + 76561197960265728 = communityid to (steam_0:1:123456) Anyways I'm not that good in php, I would apriciate any help possible. This could be in a function or just simply a sample script, or suggestions are welcome aswell. I could donate 5$ if nessesary. Thanks again upfront. Quote Link to comment Share on other sites More sharing options...
Mark Posted May 3, 2013 Share Posted May 3, 2013 http://steamidfinder.com/ Quote Link to comment Share on other sites More sharing options...
Papa John Posted May 4, 2013 Share Posted May 4, 2013 (edited) function getFriendId($steamId) { //Test input steamId for invalid format //Example SteamID: "STEAM_X:Y:ZZZZZZZZ" $gameType = 0; //This is X. It's either 0 or 1 depending on which game you are playing (CSS, L4D, TF2, etc) $authServer = 0; //This is Y. Some people have a 0, some people have a 1 $clientId = ''; //This is ZZZZZZZZ. //Remove the "STEAM_" $steamId = str_replace('STEAM_', '' ,$steamId); //Split steamId into parts $parts = explode(':', $steamId); $gameType = $parts[0]; $authServer = $parts[1]; $clientId = $parts[2]; //Calculate friendId $result = bcadd((bcadd('76561197960265728', $authServer)), (bcmul($clientId, '2'))); return $result; } Took all of five seconds to search on google, it is fairly simply to code as well... Edited May 4, 2013 by Papa John Quote Link to comment Share on other sites More sharing options...
Priceless Posted May 4, 2013 Author Share Posted May 4, 2013 Thanks alot. I've been searching myself, didnt find anything, but well. thanks =D Quote Link to comment Share on other sites More sharing options...
Priceless Posted May 4, 2013 Author Share Posted May 4, 2013 (edited) well something went wrong.. function getFriendId($steamId) { //Test input steamId for invalid format //Example SteamID: "STEAM_X:Y:ZZZZZZZZ" $gameType = 0; //This is X. It's either 0 or 1 depending on which game you are playing (CSS, L4D, TF2, etc) $authServer = 0; //This is Y. Some people have a 0, some people have a 1 $clientId = ''; //This is ZZZZZZZZ. //Remove the "STEAM_" $steamId = str_replace('STEAM_', '' ,$steamId); //Split steamId into parts $parts = explode(':', $steamId); $gameType = $parts[0]; $authServer = $parts[1]; $clientId = $parts[2]; //Calculate friendId $result = bcadd((bcadd('76561197960265728', $authServer)), (bcmul($clientId, '2'))); return $result; } if(empty($_POST) === false) { $steamId = $_POST['steamid']; echo '<a href="http://steamcommunity.com/profiles/' . getFriendId($steamId) . '">Community </a>'; } Got wrong url and it added ,000000000 (the url that came with my steamid http://steamcommunity.com/profiles/76561197993906207.0000000000) Edited May 4, 2013 by Priceless Quote Link to comment Share on other sites More sharing options...
Papa John Posted May 4, 2013 Share Posted May 4, 2013 (edited) Ok, I guess I will just make one. <? public function SteamIDtoCommunityID($steamID) { // Remove extra STEAM_ in front //Result: STEAM_0:X:XXXXXX -> 0:X:XXXXXX $steamID = str_replace("STEAM_", "", $steamID); // Explode splits the string at all :'s //Result: 0:X:XXXXXX -> $steamID[0] = 0, $steamID[1] = X, $steamID[2] = XXXXXX $steamID = explode(":", $steamID); // Use Math $steamID = ($steamID[2] * 2 + $steamID[1]) + 76561197960265728; return "http://steamcommunity.com/profiles/" . $steamID; } ?> Now if your web host runs on a 32-bit system it obviously won't be able to compute a 64-bit number. If that is the case PHP does have a few functions to help you out but I will leave that for you to figure out. Edited May 4, 2013 by Papa John Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.