Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function convertCommunityIdToSteamId($communityId) {
- $steamId1 = substr($communityId, -1) % 2;
- $steamId2a = intval(substr($communityId, 0, 4)) - 7656;
- $steamId2b = substr($communityId, 4) - 1197960265728;
- $steamId2b = $steamId2b - $steamId1;
- if($steamId2a <= 0 && $steamId2b <= 0) {
- throw new SteamCondenserException("SteamID $communityId is too small.");
- }
- return "STEAM_0:$steamId1:" . (($steamId2a + $steamId2b) / 2);
- }
- public static function convertSteamIdToCommunityId($steamId) {
- if($steamId == 'STEAM_ID_LAN' || $steamId == 'BOT') {
- throw new SteamCondenserException("Cannot convert SteamID \"$steamId\" to a community ID.");
- }
- if(preg_match('/^STEAM_[0-1]:[0-1]:[0-9]+$/', $steamId) == 0) {
- throw new SteamCondenserException("SteamID \"$steamId\" doesn't have the correct format.");
- }
- $steamId = explode(':', substr($steamId, 6));
- $steamId = $steamId[1] + $steamId[2] * 2 + 1197960265728;
- return '7656' . $steamId;
- }
Add Comment
Please, Sign In to add comment