Raised This Month: $12 Target: $400
 3% 

Convert STEAMID to Steam Community ID


Post New Thread Reply   
 
Thread Tools Display Modes
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 01-25-2014 , 13:02   Re: Convert STEAMID to Steam Community ID
Reply With Quote #331

Quote:
Originally Posted by Leonardo View Post
anyways, is it important?
this section is for snippets and tutorials for SourceMod plugins, not server plugins.
Well, someone posted a "compressed", more portable code of this converter, and I asked what programming language that was ...
__________________
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
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2014 , 18:56   Re: Convert STEAMID to Steam Community ID
Reply With Quote #332

Quote:
Originally Posted by rautamiekka View Post
compressed
Spoiler


Last edited by Leonardo; 01-25-2014 at 18:57.
Leonardo is offline
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 01-25-2014 , 18:59   Re: Convert STEAMID to Steam Community ID
Reply With Quote #333

Quote:
Originally Posted by Leonardo View Post
Spoiler

Even I can do that ;)
__________________
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
vishiswoz
New Member
Join Date: May 2014
Old 05-26-2014 , 08:13   Re: Convert STEAMID to Steam Community ID
Reply With Quote #334

This is a really awesome code that you all have created, and it's super helpful.

One question though,

If you have a URL for example like this
http://steamcommunity.com/id/alibaab

From what I've read and understood, http://steamcommunity.com/id/alibaab is the person's custom URL, and that's associated with a Steam 64 id and a Steam id. How would you grab both of these things if someone just inputted their profile name into a textbox?

In other words, how would i convert a custom url into a steam id/steam 64 id?

Thanks in advance.

Last edited by vishiswoz; 05-26-2014 at 11:07.
vishiswoz is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-26-2014 , 11:58   Re: Convert STEAMID to Steam Community ID
Reply With Quote #335

Quote:
Originally Posted by vishiswoz View Post
This is a really awesome code that you all have created, and it's super helpful.

One question though,

If you have a URL for example like this
http://steamcommunity.com/id/alibaab

From what I've read and understood, http://steamcommunity.com/id/alibaab is the person's custom URL, and that's associated with a Steam 64 id and a Steam id. How would you grab both of these things if someone just inputted their profile name into a textbox?

In other words, how would i convert a custom url into a steam id/steam 64 id?

Thanks in advance.
A relatively easy way would be to add "?xml=1" to the end of your normal URL and connect to http://steamcommunity.com/id/alibaab/?xml=1 and grab the SteamID64 from the XML there.

PHP Code:
<steamID64>76561198079044625</steamID64
You can then convert the SteamID64 to a regular SteamID using the language of your choice.
__________________
11530 is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-22-2014 , 04:55   Re: Convert STEAMID to Steam Community ID
Reply With Quote #336

Here are some snippets that support the new Steam3 format.

PHP (with GMP, but should be easy to convert to BCMath):

PHP Code:
function getCommunityId($steamId)
{
    
$accountId 0;

    if (
preg_match('/^STEAM_[0-9]:([0-9]):([0-9]+)$/i'$steamId$matches)) {
        
$accountId $matches[1] + ($matches[2] * 2);
    }
    if (
preg_match('/^\[U:[0-9]:([0-9]+)\]$/i'$steamId$matches)) {
        
$accountId $matches[1];
    }

    return 
gmp_strval(gmp_add('76561197960265728'$accountId));

MySQL (it's a bit of a monster):

PHP Code:
SELECT
    
(CASE
        
WHEN steam_id LIKE "STEAM_%" THEN 76561197960265728 CAST(SUBSTRING(steam_id91) AS UNSIGNED) + CAST(SUBSTRING(steam_id11) * AS UNSIGNED)
        
WHEN steam_id LIKE "[U:%]" THEN 76561197960265728 CAST(SUBSTRING(steam_id6CHAR_LENGTH(steam_id) - 6) AS UNSIGNED)
    
END) AS community_id 
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 08-22-2014 at 05:20.
DJ Tsunami is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-09-2014 , 08:29   Re: Convert STEAMID to Steam Community ID
Reply With Quote #337

I'll just leave it here.
PHP Code:
function ReadSteamID64$SteamID64 )
{
    if( !
is_numeric$SteamID64 ) ) return null;
    
$binary str_padbcdecbin$SteamID64 ), 64'0'STR_PAD_LEFT );
    return array(
        
'account'    => bindecsubstr$binary, -32 ) ),
        
'instance'    => bindecsubstr$binary, -5220 ) ),
        
'type'        => bindecsubstr$binary, -56) ),
        
'universe'    => bindecsubstr$binary, -64) )
    );
}

function 
BCDecBin$i )
{
    
bcscale);
    
$o '';
    do
    {
        
$o bcmod$i) . $o;
        
$i bcdiv$i);
    }
    while( 
bccomp$i) );
    return 
$o;

__________________

Last edited by Leonardo; 10-26-2014 at 08:25.
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-09-2014 , 10:17   Re: Convert STEAMID to Steam Community ID
Reply With Quote #338

Quote:
Originally Posted by Leonardo View Post
I'll just leave it here.
PHP Code:
function ReadSteamID64$SteamID64 )
{
    if( !
is_numeric$SteamID64 ) ) return null;
    
$binary str_padbcdecbin$SteamID64 ), 64'0'STR_PAD_LEFT );
    return array(
        
'account'    => bindecsubstr$binary, -32 ) ),
        
'instance'    => bindecsubstr$binary, -5220 ) ),
        
'type'        => bindecsubstr$binary, -56) ),
        
'universe'    => bindecsubstr$binary, -64) )
    );

I forget, has anyone mentioned in this thread yet that PHP's number type is only 32-bit on 32-bit systems? 'cause SteamID64 exceeds the size of a 32-bit int.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-11-2014 , 09:38   Re: Convert STEAMID to Steam Community ID
Reply With Quote #339

Quote:
Originally Posted by Powerlord View Post
'cause SteamID64 exceeds the size of a 32-bit int.
in this case, it stores as a string.
and this is why BCMath/GMP is being used.
__________________

Last edited by Leonardo; 10-11-2014 at 09:51.
Leonardo is offline
nomy
Senior Member
Join Date: Dec 2009
Location: United Kingdom
Old 11-15-2014 , 08:31   Re: Convert STEAMID to Steam Community ID
Reply With Quote #340

Hey guys, anyone has a block that converts Community ID (Steam64) to Steam ID? I need it for sourcemod scripting.

Last edited by nomy; 11-15-2014 at 08:32.
nomy 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 17:19.


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