Raised This Month: $ Target: $400
 0% 

Convert STEAMID to Steam Community ID


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 02-22-2009 , 21:42   Re: Convert STEAMID to Steam Community ID
Reply With Quote #11

Some MySQL stored procedures to do this for you (Note: Assumes you are entering these using the command line client, otherwise you may need to fiddle with the delimiters)

Code:
DELIMITER | 
drop function SteamToInt|

create function SteamToInt(steamid varchar(64))
RETURNS bigint(64)
BEGIN
	declare authserver int;
	declare authid int;

	set authserver = cast(substr(steamid,9,1) as unsigned integer);
	set authid = cast(substr(steamid,11) as unsigned integer);
	return 76561197960265728+(authid*2)+authserver;
END |

drop function IntToSteam|

create function IntToSteam(communityid bigint(64))
RETURNS varchar(64)
BEGIN
	declare ret varchar(64);
	declare authserver int;
	declare authid bigint;

	set communityid = communityid-76561197960265728;
	set authserver = mod(communityid,2);
	set communityid = communityid-authserver;
	set authid = communityid/2;
	set ret = concat("STEAM_0:",authserver,":",authid);
	return ret;
END |
DELIMITER ;
Usage:
Code:
select SteamToInt("STEAM_0:1:1199"), IntToSteam(76561197960268127);
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
 



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 18:14.


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