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

Convert STEAMID to Steam Community ID


Post New Thread Reply   
 
Thread Tools Display Modes
8088
Veteran Member
Join Date: Jan 2008
Old 09-26-2009 , 19:51   Re: Convert STEAMID to Steam Community ID
Reply With Quote #221

Quote:
Originally Posted by #Barracuda View Post
I've made an Ajax widget
Looks good!
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 09-27-2009 , 09:00   Re: Convert STEAMID to Steam Community ID
Reply With Quote #222

Quote:
Originally Posted by voogru View Post
Wrong.
Code:
<?php
echo 'gaben';
?>
?> is optional But you're probably better at C++ than PHP
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Lethal-
Member
Join Date: Jun 2009
Old 10-13-2009 , 07:41   Re: Convert STEAMID to Steam Community ID
Reply With Quote #223

Quote:
Originally Posted by berni View Post
This is for sourcemod scripting:

Code:
AuthIDToFriendID(String:AuthID[], String:FriendID[], size) {
    
    ReplaceString(AuthID, strlen(AuthID), "STEAM_", "");

    if (StrEqual(AuthID, "ID_LAN")) {
        FriendID[0] = '\0';
        
        return;
    }

    decl String:toks[3][16];

    ExplodeString(AuthID, ":", toks, sizeof(toks), sizeof(toks[]));

    //new unknown = StringToInt(toks[0]);
    new iServer = StringToInt(toks[1]);
    new iAuthID = StringToInt(toks[2]);

    new iFriendID = (iAuthID*2) + 60265728 + iServer;

    Format(FriendID, size, "765611979%d", iFriendID);
}
This isn't working for newer steamIDs, as they start with 765611980. Any way to fix this?
Lethal- is offline
Hawkeye-
Senior Member
Join Date: Jan 2009
Old 10-13-2009 , 09:52   Re: Convert STEAMID to Steam Community ID
Reply With Quote #224

This should work by my tests in Excel of the match/URL generation.

Code:
AuthIDToFriendID(String:AuthID[], String:FriendID[], size) {
    
    ReplaceString(AuthID, strlen(AuthID), "STEAM_", "");

    if (StrEqual(AuthID, "ID_LAN")) {
        FriendID[0] = '\0';
        
        return;
    }

    decl String:toks[3][16];

    ExplodeString(AuthID, ":", toks, sizeof(toks), sizeof(toks[]));

    //new unknown = StringToInt(toks[0]);
    new iServer = StringToInt(toks[1]);
    new iAuthID = StringToInt(toks[2]);

    new iFriendID = (iAuthID*2) + 7960265728 + iServer;

    Format(FriendID, size, "7656119%d", iFriendID);
}
Hawkeye- is offline
Lethal-
Member
Join Date: Jun 2009
Old 10-13-2009 , 12:29   Re: Convert STEAMID to Steam Community ID
Reply With Quote #225

Quote:
Originally Posted by aoHawkeye View Post
This should work by my tests in Excel of the match/URL generation.

Code:
AuthIDToFriendID(String:AuthID[], String:FriendID[], size) {
    
    ReplaceString(AuthID, strlen(AuthID), "STEAM_", "");

    if (StrEqual(AuthID, "ID_LAN")) {
        FriendID[0] = '\0';
        
        return;
    }

    decl String:toks[3][16];

    ExplodeString(AuthID, ":", toks, sizeof(toks), sizeof(toks[]));

    //new unknown = StringToInt(toks[0]);
    new iServer = StringToInt(toks[1]);
    new iAuthID = StringToInt(toks[2]);

    new iFriendID = (iAuthID*2) + 7960265728 + iServer;

    Format(FriendID, size, "7656119%d", iFriendID);
}
It didn't unfortunately.

Earlier, I tried setting the number I use in a PHP script to do this (76561197960265728). When I printed that to the server it just echoed 0.

Last edited by Lethal-; 10-13-2009 at 13:08.
Lethal- is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 11-07-2009 , 19:52   Re: Convert STEAMID to Steam Community ID
Reply With Quote #226

Any decent way to do this with Pawn? The same method holds true, but the community ID numbers are larger and pawn's intergers aren't long enough to calculate them now.

I had to make a c++ extension to calculate the player's community's id. An unsigned long long type is sufficiently long enough. I hope this wasn't the best solution. Took me a while to scrape together too.

The end result is a native that spits out a string of the client's community ID. I think it would make a useful native in sourcemod's core...if it can't be done in Pawn of course.
pheadxdll is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-08-2009 , 01:52   Re: Convert STEAMID to Steam Community ID
Reply With Quote #227

Quote:
Originally Posted by pheadxdll View Post
I had to make a c++ extension to calculate the player's community's id. An unsigned long long type is sufficiently long enough. I hope this wasn't the best solution. Took me a while to scrape together too.

The end result is a native that spits out a string of the client's community ID. I think it would make a useful native in sourcemod's core...if it can't be done in Pawn of course.
I already wrote and released one for that.

http://forums.alliedmods.net/showthr...light=csteamid

Last edited by bl4nk; 11-08-2009 at 01:56.
bl4nk is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 11-08-2009 , 02:31   Re: Convert STEAMID to Steam Community ID
Reply With Quote #228

Oh wow, that was exactly what I needed. Well, hopefully someone will see this at least and not make the same mistake.
pheadxdll is offline
DarthNinja
SourceMod Plugin Approver
Join Date: Mar 2009
Location: PreThinkHook()
Old 11-25-2009 , 20:31   Re: Convert STEAMID to Steam Community ID
Reply With Quote #229

Here's some php I wrote to calculate Steam Community IDs using php's basic math functions.
(No php extensions required )


PHP Code:
//Get SteamID and save it to $steam_id somehow

<?php
$steam_id
=strtolower($steamid);
if (
substr($steam_id,0,7)=='steam_0') {
$tmp=explode(':',$steam_id);
}
if ((
count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
 
 
//The 'Magic Number': 76561197960265728
 //Split up so it can be calculated without an extension.
 

 
$steamidCalc=($tmp[2]*2)+$tmp[1]; //Work out step 1
$calckey='1197960265728'//Second bit of the magic number
$pre='7656'//First bit of the magic number
    
$steamcid=$steamidCalc+$calckey//works out the ending of the steam community ID
    
$link="http://steamcommunity.com/profiles/";
echo 
$link; echo $pre; echo $steamcid;
 
 };

?>
By breaking off a few digit, it prevents php from outputting the number using scientific notation.
This does however, mean that this will have to be updated once there are enough steam accounts to make the numbers roll over.

Hope that's helpful to someone
__________________
DarthNinja is offline
jimbodude
Member
Join Date: Mar 2009
Location: England
Old 12-30-2009 , 17:23   Re: Convert STEAMID to Steam Community ID
Reply With Quote #230

Any way to make a php script redirect to the Steam Community page, for example, steamid.php?STEAM_.. would redirect to the corresponding Steam Community page?
__________________
jimbodude is offline
Reply



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 22:17.


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