Last active
February 1, 2024 14:34
-
-
Save aligatorr89/eccdd4352bf0055ca8d347c01b3044bd to your computer and use it in GitHub Desktop.
Convert SteamID3 to SteamID64 - Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert SteamID3 to SteamID64 | |
// Use big js for precision with big numbers | |
const Big = require('big.js'); | |
/* | |
* Example: '[U:1:927695233]' -> '76561198887960961' | |
* https://www.steamidfinder.com/lookup/U%3A1%3A927695233/ | |
*/ | |
function convertSteamId3ToSteamId64(steamId3) { | |
const accountId = steamId3.replace('[', '').replace(']', '').split(':')[2]; | |
// 76561197960265728 is Valve's magic constant | |
return Big(accountId).plus('76561197960265728').toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment