AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Convert STEAMID to Steam Community ID (https://forums.alliedmods.net/showthread.php?t=60899)

voogru 09-16-2007 00:09

Convert STEAMID to Steam Community ID
 
I figured I would share this little snippet, this will convert a STEAMID to the a players friendID which is used for steam community.

What could potentially be done with this, is to fetch data on a player, see what groups he is in, and basically gives you the flexibility to ban whole groups from your server without knowing all of their steamids.

At least, thats what I intend to do with it. You can also of course do the reverse, converting friend ID's to steamids.

PHP Code:

__int64 GetFriendID( const char *pszAuthID )
{
    if(!
pszAuthID)
        return 
0;

    
int iServer 0;
    
int iAuthID 0;

    
char szAuthID[64];
    
strcpy_s(szAuthID63pszAuthID);

    
char *szTmp strtok(szAuthID":");
    while(
szTmp strtok(NULL":"))
    {
        
char *szTmp2 strtok(NULL":");
        if(
szTmp2)
        {
            
iServer atoi(szTmp);
            
iAuthID atoi(szTmp2);
        }
    }

    if(
iAuthID == 0)
        return 
0;

    
__int64 i64friendID = (__int64)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;


Have fun.

Edit: Using this a Pure MySQL was created

Nican 09-16-2007 00:22

Re: Convert STEAMID to Steam Community ID
 
Really interesting data...

I would never have thought there was a relation ship

+Karma for you

BAILOPAN 09-16-2007 10:36

Re: Convert STEAMID to Steam Community ID
 
That's pretty awesome, voogru. I'm curious as to how you discovered this -- observation with some trial and error?

out of boredom I went and looked up the first few steamids to see how many were definitely valve employees:
Code:

steam_0:0:1 (alfred)
steam_0:1:1 (ErikJ)
steam_0:1:2 (alfred)
steam_0:0:5 (greg coomer)
steam_0:0:6 (john cook)
steam_0:1:7 (taylor sherman)
steam_0:0:8 (chris bokitch)
steam_0:1:9 (lyncho?)
steam_0:1:10 (eric smith)


voogru 09-16-2007 13:10

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by BAILOPAN (Post 531878)
That's pretty awesome, voogru. I'm curious as to how you discovered this -- observation with some trial and error?

out of boredom I went and looked up the first few steamids to see how many were definitely valve employees:
Code:

steam_0:0:1 (alfred)
steam_0:1:1 (ErikJ)
steam_0:1:2 (alfred)
steam_0:0:5 (greg coomer)
steam_0:0:6 (john cook)
steam_0:1:7 (taylor sherman)
steam_0:0:8 (chris bokitch)
steam_0:1:9 (lyncho?)
steam_0:1:10 (eric smith)


A bit of trial and error.

I got the friendID for these two ID's:

STEAM_0:1:1182 (76561197960268093)
STEAM_0:1:30679 (76561197960327087)

I noticed that the 2 friend ID's were identicle up until 11th number.
76561197960 268093
76561197960 327087

Then I tried this:

76561197960327087 - 76561197960268093 = 58994

Result was higher than expected, so I cut it in half for giggles.

58994 / 2 = 29497

Hmm.. not too far from 30679..

29497 + 1182 = 30679 DING DING DING DING

and

30679 - 29497 = 1182 DING DING DING DING

:D

To get the first number, I then did:

76561197960268093 - (1182 * 2) = 76561197960265729

But, I use the 76561197960265728 number and then just increment it by what the auth server is.

There does not appear to be a STEAM_0:0:0 ID, but there is a STEAM_0:1:0 ID.

Now with this knowledge, I also have the option of storing steamid's as 64 bit ints rather than strings.

My question to valve is where the hell did they pull out a number like 76561197960265728.

A friend of mine pointed out when it's converted to hex it's 110000100000000, but no idea if that is significant or not.

M249-M4A1 09-16-2007 23:16

Re: Convert STEAMID to Steam Community ID
 
holy cow

Extreme_One 09-17-2007 18:34

Re: Convert STEAMID to Steam Community ID
 
Wow

That's really clever!

BAILOPAN 09-17-2007 19:00

Re: Convert STEAMID to Steam Community ID
 
voogru: thanks for the logic path behind that :)

Of course you could just store them as 32-bit integers if you wanted... if you just do the X*2 + 1, it will be a long time before they overflow. Nice idea either way for lookup algorithms.

voogru 09-17-2007 23:13

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by BAILOPAN (Post 532436)
voogru: thanks for the logic path behind that :)

Of course you could just store them as 32-but integers if you wanted... if you just do the X*2 + 1, it will be a long time before they overflow. Nice idea either way for lookup algorithms.

Yeah, I realized that, but what if someday valve takes over the world and has more than 4 billion steam accounts?

M249-M4A1 09-18-2007 22:06

Re: Convert STEAMID to Steam Community ID
 
Quote:

Originally Posted by voogru (Post 532495)
Yeah, I realized that, but what if someday valve takes over the world and has more than 4 billion steam accounts?

stop hacking the pentagon

Lee 11-17-2007 16:04

Re: Convert STEAMID to Steam Community ID
 
You should post this in the AMXX section too.


All times are GMT -4. The time now is 16:46.

Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.