Raised This Month: $32 Target: $400
 8% 

Convert STEAMID to Steam Community ID


Post New Thread Reply   
 
Thread Tools Display Modes
willgtl
Junior Member
Join Date: Jan 2010
Old 04-26-2010 , 11:04   Re: Convert STEAMID to Steam Community ID
Reply With Quote #241

I'm a pretty big noob with PHP coding, maybe someone can figure out why this isn't working:

Code:
            $steamid = $row->steamId;
            $community_id = ((substr($steamid, 10)) * 2) + 76561197960265728 + (substr($steamid, 8, 1)); 
            $community_id = rtrim(sprintf("%f", $community_id), "0");
            $community_id = (string)$community_id;
            $community_id = str_replace(".", "", $community_id);

                echo '<a href="http://steamcommunity.com/profiles/'.$community_id.'">View SteamID Page</a>';
Using my SteamID (STEAM_0:0:16672270) it figures the community ID is 76561197993610272, which it isn't. Where did I go wrong?
willgtl is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-26-2010 , 14:16   Re: Convert STEAMID to Steam Community ID
Reply With Quote #242

PHP Code:
$community_id = ((substr($steamid10)) * 2) + 1197960265728 + (substr($steamid81));
$community_id'7656'.$community_id;
echo 
'<a href="http://steamcommunity.com/profiles/'.$community_id.'">View SteamID Page</a>'
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
matt.b
BANNED
Join Date: Apr 2010
Old 05-10-2010 , 19:45   Re: Convert STEAMID to Steam Community ID
Reply With Quote #243

hello, where might i be able to get this script and install it on my forum



would i add the script onto my webhosting through ftp

i tried that script but it didn't work i put it in my webhosting public_html steamidconv.php nothing

if anyone can help

thanks
matt.b is offline
Broseph
Junior Member
Join Date: Aug 2009
Old 05-10-2010 , 20:19   Re: Convert STEAMID to Steam Community ID
Reply With Quote #244

Made a website out of it:

www.steamidfinder.com

Thanks OP :p
Broseph is offline
Landmine
Junior Member
Join Date: Jan 2009
Old 05-20-2010 , 16:26   Re: Convert STEAMID to Steam Community ID
Reply With Quote #245

Another website http://www.elementsystems.net/ this one keeps a history of your past searches, pretty handy.

http://www.elementsystems.net/Tools/...estigator.aspx

Last edited by Landmine; 05-20-2010 at 16:27. Reason: Added direct link to the page
Landmine is offline
Durzel
Member
Join Date: Aug 2008
Old 05-25-2010 , 09:36   Re: Convert STEAMID to Steam Community ID
Reply With Quote #246

Apologies for being a bit slow, have read through a few pages of this thread but haven't found the answer.

I can see how this would be used (in all its different programming language guises) externally to the game, but how would one use this as part of a SourceMod?

Would you need to somehow interface with MySQL, an external webpage or whatever that has the code/stored procedure on it - or can this be done natively within SM?
Durzel is offline
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 05-25-2010 , 10:15   Re: Convert STEAMID to Steam Community ID
Reply With Quote #247

Would someone mind to write the code in plain English so that I can actually understand it ? I just found out that the "*" behind an variable's name means it's a pointer to somewhere, which immediately gave me impossible feeling. One of the good reason why I hate C++
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
1Swat2KillThemAll
SourceMod Donor
Join Date: Nov 2009
Old 07-26-2010 , 06:36   Re: Convert STEAMID to Steam Community ID
Reply With Quote #248

This should help you, and I even included my version of SteamCommunity -> SteamID
Code:
//Note: I changed all __int64 to long long
//See first post for original
long long GetFriendID(const char *pszAuthID)
{
 //pointer is invalid
    if(!pszAuthID)
        return 0;
 //steam_x:y
 //x
    int iServer = 0;
    //y
 int iAuthID = 0;
 //copy string from pointer into sz_AuthID
    char szAuthID[64];
    strcpy_s(szAuthID, 63, pszAuthID);
 //remove the :'s and retrieve iServer/iAuthID
 //for more information:
 //http://www.cplusplus.com/reference/clibrary/cstring/strtok/
    char *szTmp = strtok(szAuthID, ":");
    while(szTmp = strtok(NULL, ":"))
    {
        char *szTmp2 = strtok(NULL, ":");
        if(szTmp2)
        {
            iServer = atoi(szTmp);
            iAuthID = atoi(szTmp2);
        }
    }
 //retrieval failed
    if(iAuthID == 0)
        return 0;
 //magic
    long long i64friendID = (long long)iAuthID * 2;
    //Friend ID's with even numbers are the 0 auth server.
    //Friend ID's with odd numbers are the 1 auth server.
    i64friendID += 76561197960265728 + iServer; 
    return i64friendID;
}
string GetSteamID(long long CommunityID)
{
 //the x out of steam_0:x:y
 int firstnumber = 0;
 //stringstream enables you to treat a string like a stream,
 //like cin (used to convert int to string here)
 stringstream ret;
 //decide whether the first number is a 0 or a 1
 //and make sure its even so there won't be any
 //rounding errors with the next division
 if (CommunityID % 2) { CommunityID--; firstnumber = 1; }
 CommunityID = (CommunityID - 76561197960265728) / 2;
 
 //build steamid
 ret << "STEAM_0:" << firstnumber << ":" << CommunityID;
 
 //return steamid
 return ret.str();
}
And for the record: there are no reasons to hate c++ =)
1Swat2KillThemAll is offline
nunoabc
Senior Member
Join Date: Aug 2007
Location: Portugal, VN Gaia
Old 08-22-2010 , 13:24   Re: Convert STEAMID to Steam Community ID
Reply With Quote #249

I'm currently doing two PHP scripts. One does the job similar to the SteamProfile and the other one is like NoobSticks SteamID converter. While I am doing it, I tried to write it mathematically (more or less) so that the persons that don't understand any other explication could understand and I came up with this:
Code:
Base = 76561197960265728
SteamID = STEAM_0:Server:ID (= STEAM_0:0:15973075)
ProfileID = Base + Server + 2 x ID (= 76561197992211878)

IDtemp = ProfileID - Base (= 31946150)
Server = IDtemp % 2 (= 0)
ID = (IDtemp - Server) / 2 (= 15973075)
SteamID = STEAM_0:Server:ID = STEAM_0:0:15973075
Notes:
  • Base it's the value corresponding to the following SteamID: STEAM_0:0:0;
  • Server is something I saw (or I think I saw) someone calling to the second part of the SteamID;
  • Regarding the IDtemp variable, I thought that this way it would be more simpler;
  • The % sign refers to modulus operator in PHP, which gives us the remainder of a division. So in this case it's the remainder of IDtemp divided by 2;
  • The SteamID here used is mine, so if you have any questions, you can use my steam page to leave a comment.
If for some reason the final result isn't what is expected, please let me now. If everything is correct, I would really like to know as well.
__________________

Last edited by nunoabc; 08-22-2010 at 18:38.
nunoabc is offline
cooltruck
Member
Join Date: Oct 2010
Old 10-09-2010 , 03:22   Re: Convert STEAMID to Steam Community ID
Reply With Quote #250

Yeah I'm having some trouble setting this up on my smf forum php everything shows up ok, problem is when I input a steam id/url it refreshes the page not giving out the output. I used this:

https://forums.alliedmods.net/showpo...&postcount=118

Last edited by cooltruck; 10-09-2010 at 03:26.
cooltruck is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode