Rules FAQ Members List Search Register Login

 Raised This Month: \$399 Target: \$400 99%   Almost there!

pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
 07-15-2016 , 17:10   Re: Convert STEAMID to Steam Community ID #351 This is a snippet I wrote for sourcepawn, but I won't use anymore. Will convert Steam64 string to steam32 int Don't even know if this will be of use for anyone. This was built based on this PHP Code: ``` // 64 bit max is 19 numbers + 1 (for teminator)#define MAX_STEAM64_LENGTH 20// 11 numbers is the total numbers that the 32 bit can hold, lets make sure its less than that by 1.// 10 + terminator#define MAX_INTEGERS 11stock bool GetSteam32FromSteam64(const char szSteam64Original[MAX_STEAM64_LENGTH], int &iSteam32){    char szSteam32[MAX_STEAM64_LENGTH];    char szSteam64[MAX_STEAM64_LENGTH];        // We don't want to actually edit the original string.    // We make a new string for the editing.    strcopy(szSteam64, sizeof szSteam64, szSteam64Original);        // Remove the first three numbers    ReplaceStringEx(szSteam64, sizeof(szSteam64), "765", "");        // Because pawn does not support numbers bigger than 2147483647, we will need to subtract using a combination of numbers.    // The combination can be    // 1 number to MAX_INTEGERS    char szSubtractionString[] = "61197960265728";        // First integer is the integer from szSteam64    // Second is from the subtraction string szSubtractionString    char szFirstInteger[MAX_INTEGERS], szSecondInteger[MAX_INTEGERS];    int iFirstInteger, iSecondInteger;        char szResultInt[MAX_INTEGERS];        // Ugly hack    // Make the strings 00000000000 so when we use StringToInt the zeroes won't affect the result    // sizeof - 1 because we need the last End of string (0) byte;    SetStringZeros(szFirstInteger, sizeof(szFirstInteger), sizeof(szFirstInteger) - 1);    SetStringZeros(szSecondInteger, sizeof(szSecondInteger), sizeof(szSecondInteger) - 1);    // Start from the end of the string, because subtraction should always start from the first number in the right.    int iResultInt;        int iSteam64Position = strlen(szSteam64);    int iIntegerPosition = strlen(szFirstInteger);        int iNumCount;    int iResultLen;    char szStringZeroes[MAX_INTEGERS];        while(--iSteam64Position > -1)    {        iIntegerPosition -= 1;                ++iNumCount;        szFirstInteger[iIntegerPosition] = szSteam64[iSteam64Position];        szSecondInteger[iIntegerPosition] = szSubtractionString[iSteam64Position];                iFirstInteger = StringToInt(szFirstInteger);        iSecondInteger = StringToInt(szSecondInteger);                    // Can we subtract without getting a negative number?        if(iFirstInteger >= iSecondInteger)        {            iResultInt = iFirstInteger - iSecondInteger;            // 69056897            PrintToServer("Subtract %s from %s = %d", szFirstInteger, szSecondInteger, iResultInt);            if(iResultInt)            {                IntToString(iResultInt, szResultInt, sizeof szResultInt);                                if( iNumCount != (iResultLen  = strlen(szResultInt) ) )                {                    SetStringZeros(szStringZeroes, sizeof szStringZeroes, iNumCount - iResultLen);                }                                else                {                    szStringZeroes = "";                }            }                        else            {                szResultInt = "";                                SetStringZeros(szStringZeroes, sizeof szStringZeroes, iNumCount);                PrintToServer("String Zeroes: %s", szResultInt);            }                        Format(szSteam32, sizeof szSteam32, "%s%s%s", szStringZeroes, szResultInt, szSteam32);            PrintToServer("Current Progress: %s", szSteam32);                        // Reset our stuff.            SetStringZeros(szFirstInteger, sizeof(szFirstInteger), sizeof(szFirstInteger) - 1);            SetStringZeros(szSecondInteger, sizeof(szSecondInteger), sizeof(szSecondInteger) - 1);                        iIntegerPosition = strlen(szFirstInteger);            iNumCount = 0;        }                if(iIntegerPosition - 1 < 0)        {            // We failed, and this calculation can not be done in pawn.            return false;        }                // if not, lets add more numbers.    }        iSteam32 = StringToInt(szSteam32);    return true;}void SetStringZeros(char[] szString, int iSize, int iNumZeros){    int i;    for(i = 0; i < iNumZeros && i < iSize; i++)    {        szString[i] = '0';    }        szString[i] = 0;}  ``` __________________ اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه No longer active in AMXX. Sorry. Last edited by pokemonmaster; 07-15-2016 at 17:15.
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
 04-14-2017 , 23:31   Re: Convert STEAMID to Steam Community ID #352 Don't mean to bump an oldish thread but this might save someone a tiny bit of time later.... Here is the Sourcemod adaption of YamiKaitou's code here with asherkin's tip: https://forums.alliedmods.net/showpo...&postcount=341 https://forums.alliedmods.net/showpo...&postcount=342 So far its passed all my tests but let me know if you find any issues. PHP Code: ``` stock void GetSteamId2(const char[] szSteam64, char[] szSteam2, int iLen) {   char szBase[18] = "76561197960265728";   int iBorrow = 0;   char szSteam[18];   char szAccount[18];   int iY = 0;   int iZ = 0;   int iTemp = 0;      //Copy steamid64 Over   Format(szSteam, sizeof(szSteam), szSteam64);      //Determine iY   if (intval(szSteam[16]) % 2 == 1) {     iY = 1;     szSteam[16] = strval(intval(szSteam[16]) - 1);   }      //Determine szAccount   for (int k = 16; k >= 0; --k) {     if (iBorrow > 0) {       iTemp = intval(szSteam[k]) - 1;              if (iTemp >= intval(szBase[k])) {         iBorrow = 0;         szAccount[k] = strval(iTemp - intval(szBase[k]));       }       else {         iBorrow = 1;         szAccount[k] = strval((iTemp + 10) - intval(szBase[k]));       }     }     else {       if (intval(szSteam[k]) >= intval(szBase[k])) {         iBorrow = 0;         szAccount[k] = strval(intval(szSteam[k]) - intval(szBase[k]));       }       else {         iBorrow = 1;         szAccount[k] = strval((intval(szSteam[k]) + 10) - intval(szBase[k]));       }     }   }      //Divide szAccount answer by 2   iZ = StringToInt(szAccount) / 2;      //Construct final steam2 id   Format(szSteam2, iLen, "STEAM_1:%d:%d", iY, iZ); } int strval(const int iNum) {   return '0' + ((iNum >= 0 && iNum <= 9) ? iNum : 0); } int intval(int cNum) {   return (cNum >= '0' && cNum <= '9') ? (cNum - '0') : 0; }  ``` __________________ STEAM: /id/invexbyte | Github: Mo Beigi | Discord: Byte#0017 Community: Invex Gaming | My Plugins: Click Me!
waylander3
Senior Member
Join Date: Sep 2015
Location: Russia, Norilsk
 08-05-2017 , 14:36   Re: Convert STEAMID to Steam Community ID #353 Hey guys, how can i convert U:1:0 to STEAM:1:0? From steamID3 to steamID Last edited by waylander3; 08-05-2017 at 14:48.
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
08-06-2017 , 17:07   Re: Convert STEAMID to Steam Community ID
#354

Quote:
 Originally Posted by waylander3 Hey guys, how can i convert U:1:0 to STEAM:1:0? From steamID3 to steamID
From "[U:1:1532443]":

1532443 / 2 = 766221,5

Since the number is odd, it is then "STEAM_1:1:766221".

If the number was didn't give an odd number, e.g. "766221", it would have been "STEAM_1:0:766221"
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
waylander3
Senior Member
Join Date: Sep 2015
Location: Russia, Norilsk
08-06-2017 , 20:14   Re: Convert STEAMID to Steam Community ID
#355

Quote:
 Originally Posted by arne1288 From "[U:1:1532443]": 1532443 / 2 = 766221,5 Since the number is odd, it is then "STEAM_1:1:766221". If the number was didn't give an odd number, e.g. "766221", it would have been "STEAM_1:0:766221"
No, i mean on server. On my server (dota 2) i have U: format (in "status"), and i need STEAM: format.
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
08-07-2017 , 08:09   Re: Convert STEAMID to Steam Community ID
#356

Quote:
 Originally Posted by waylander3 No, i mean on server. On my server (dota 2) i have U: format (in "status"), and i need STEAM: format.
It sounded like you wanted the formula for converting it..

If you want the "status" command to show different output, you need to create a plugin that does it exactly as you want.

If you have any other plugins showing the one where you want the other, you need to adjust those plugins yourself, or hire someone to do it for you.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
 09-27-2017 , 02:05   Re: Convert STEAMID to Steam Community ID #357 Note that the number 76561197960265728 looks like a constant, but it really isn't. This doesn't really matter if you're converting SteamId2 to SteamId64 because SteamId2 only supports individual user accounts. However, SteamId3 also contains the account type and (optionally) instance ID. The correct calculation for Community IDs: Code: `((universe << 56) | (accountType << 52) | (instance << 32) | accountId)` The first 3 default to 1 for individual user accounts, which means the "magic number" for individual accounts is Code: `((1L << 56) | (1L << 52) | (1L << 32))` which is 76561197960265728. (L is there because 64-bit literals need it in the language I was using to double check this.) If you try this to get group profile IDs or game server profile IDs, it fails spectacularly because they use different account types and instances. Side note: The second section of a SteamId2 is the lowest bit of the account ID and the third section is the remaining 31 bits of the account ID. Hence, to get the account ID, it's ((third section << 1) | second section) __________________ Am I back? Well, we'll see. Last edited by Powerlord; 09-27-2017 at 02:09.
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
09-27-2017 , 02:25   Re: Convert STEAMID to Steam Community ID
#358

Quote:
 Originally Posted by Powerlord Note that the number 76561197960265728 looks like a constant, but it really isn't. This doesn't really matter if you're converting SteamId2 to SteamId64 because SteamId2 only supports individual user accounts. However, SteamId3 also contains the account type and (optionally) instance ID. The correct calculation for Community IDs: Code: `((universe << 56) | (accountType << 52) | (instance << 32) | accountId)` The first 3 default to 1 for individual user accounts, which means the "magic number" for individual accounts is Code: `((1L << 56) | (1L << 52) | (1L << 32))` which is 76561197960265728. (L is there because 64-bit literals need it in the language I was using to double check this.) If you try this to get group profile IDs or game server profile IDs, it fails spectacularly because they use different account types and instances. Side note: The second section of a SteamId2 is the lowest bit of the account ID and the third section is the remaining 31 bits of the account ID. Hence, to get the account ID, it's ((third section << 1) | second section)
Very good to know, thank you a lot.
__________________
Quote:
Big thanks to all who gave Karma
4ever16
Veteran Member
Join Date: Apr 2015
03-12-2020 , 07:19   Re: Convert STEAMID to Steam Community ID
#359

Quote:
 Originally Posted by DarthNinja 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 ``` 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
Thanks!

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 23:17.

 DMCA - Archive - Top