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

Full SteamID Converter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 05-06-2020 , 12:45   Full SteamID Converter
Reply With Quote #1

Would anyone here know how to convert SteamID's to and from the 3 different types via SourceMod? I've seen a few examples spread around, but no clear way to convert between all 3 types.

Formats
  • SteamID64, 12345678901234567
  • SteamID3, [U:1:23456789]
  • SteamID2, STEAM_0:1:23456789

Example Functions:

SteamID64
PHP Code:
ConvertSteamID64to3(SteamID64SteamID3)
ConvertSteamID64to2(SteamID64SteamID2
SteamID3
PHP Code:
ConvertSteamID3to64(SteamID3SteamID64)
ConvertSteamID3to2(SteamID3SteamID2
SteamID2
PHP Code:
ConvertSteamID2to64(SteamID2SteamID64)
ConvertSteamID2to3(SteamID2SteamID3
Many thanks for any help on this!
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 05-06-2020 , 17:14   Re: Full SteamID Converter
Reply With Quote #2

PHP Code:

// 23456789 (from [U:1:23456789]) to STEAM_1:1:23456789
int GetSteam2FromAccountId(char[] resultint maxlenint account_id)
{
    return 
Format(resultmaxlen"STEAM_1:%d:%d"view_as<bool>(account_id 2), account_id 2);
}

// STEAM_1:1:23456789 to 23456789
int GetAccountIdFromSteam2(const char[] steam_id)
{
    
Regex exp = new Regex("^STEAM_[0-5]:[0-1]:[0-9]+$");
    
int matches exp.Match(steam_id);
    
delete exp;
    
    if (
matches != 1)
    {
        return 
0;
    }
    
    return 
StringToInt(steam_id[10]) * + (steam_id[8] - 48);
}

// 23456789 (from [U:1:23456789]) to 12345678901234567
int GetSteam64FromAccountId(int account_id)
{
    return 
account_id 76561197960265728;
}

int GetAccountIdFromSteam64(int steam64)
{
    return 
steam64 76561197960265728;

__________________
Ilusion9 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 03:48.


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