Raised This Month: $32 Target: $400
 8% 

Convert STEAMID to Steam Community ID


Post New Thread Reply   
 
Thread Tools Display Modes
WaLLy3K
Junior Member
Join Date: May 2008
Location: Queensland, Australia.
Old 02-17-2009 , 05:23   Re: Convert STEAMID to Steam Community ID
Reply With Quote #131

Yeah, it's a complete load of crap (at first, at least) that Valve decided to change it for L4D and TF2 - most people just didn't realise and (I) thought that it like, just a new auth server or something. Never having to look at my own Steam ID in L4D, I never saw that my own ID had changed.

It should all now just be 1 instead of having it mixed between orangebox and non orangebox.
__________________


Last edited by WaLLy3K; 02-17-2009 at 07:30.
WaLLy3K is offline
Send a message via MSN to WaLLy3K
voogru
Inspector Javert
Join Date: Oct 2004
Old 02-17-2009 , 13:29   Re: Convert STEAMID to Steam Community ID
Reply With Quote #132

Everyone should just switch to using the 32 bit int version of the STEAM ID's for everything.

Future proof that way, and works all over.
voogru is offline
BAILOPAN
Join Date: Jan 2004
Old 02-18-2009 , 10:32   Re: Convert STEAMID to Steam Community ID
Reply With Quote #133

Quote:
Originally Posted by voogru View Post
Everyone should just switch to using the 32 bit int version of the STEAM ID's for everything.

Future proof that way, and works all over.
It's not and there's little convincing reason to believe this, for redistributable plugins. The intermediary formats are irrelevant, users only care about the input format. In terms of compatibility, as long as there exists a conversion algorithm, values can be normalized internally to anything with no usability expense.

Such a conversion algorithm isn't a real guarantee in the first place, so this is moot, or even refuted - instead a Steam ID in a database should be a tuple of [type, identifier], which is implicitly preserved (unoptimally) in using the straight string format.

This isn't to say that there is no value in converting Steam IDs to integers. It's not a panacea though. As with everything Valve does, I will tread carefully until a solution is verifiably required. After all, the TF2 change was reverted pretty quickly.
__________________
egg

Last edited by BAILOPAN; 02-18-2009 at 10:42.
BAILOPAN is offline
voogru
Inspector Javert
Join Date: Oct 2004
Old 02-18-2009 , 21:13   Re: Convert STEAMID to Steam Community ID
Reply With Quote #134

Quote:
Originally Posted by BAILOPAN View Post
It's not and there's little convincing reason to believe this, for redistributable plugins. The intermediary formats are irrelevant, users only care about the input format. In terms of compatibility, as long as there exists a conversion algorithm, values can be normalized internally to anything with no usability expense.

Such a conversion algorithm isn't a real guarantee in the first place, so this is moot, or even refuted - instead a Steam ID in a database should be a tuple of [type, identifier], which is implicitly preserved (unoptimally) in using the straight string format.

This isn't to say that there is no value in converting Steam IDs to integers. It's not a panacea though. As with everything Valve does, I will tread carefully until a solution is verifiably required. After all, the TF2 change was reverted pretty quickly.
Theres a new GetClientSteamID on IVEngineServer that returns a CSteamID instance, I think it's a matter of time before valve actually changes the steamid strings, the ID's themselves will be the same (at least I suspect), just they will change it's representation as a string.

I've actually decided to store them as 64 bit ints (same as SteamCommunity ID's) now.
voogru is offline
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 #135

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
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 02-25-2009 , 03:10   Re: Convert STEAMID to Steam Community ID
Reply With Quote #136

Damn i still don't get it how this converting works!
I think we all know AMXBans and i'm trying to add this converting technique to it so when you click on a steamID you automaticly go to the steam community page for the banned player.

I see al huge scripts here in this topic and i don't understand what they actualy are doing or how to add them, i'm just looking for a simple script which only convert the steamID to the communityID.

For example:
$steamid = $result->player_id;
$community_id = "convert $steamid
to steam_communityID";

Then i can use the below line in the template:
<td><a href='
http://steamcommunity.com/profiles/{$community_id}'>{$bans.player_id}</a></td>

Anyone know how to write the red part in working PHP language or is it just not possible to use it together with the AMXBans script?
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.
Maurice is offline
Gizmo
Senior Member
Join Date: May 2006
Location: Sweden
Old 02-25-2009 , 03:47   Re: Convert STEAMID to Steam Community ID
Reply With Quote #137

Add this in the amxbans query and make a link of the steamid with the comid, i hope you know what i mean, im not to good in explaning, player_id is the field in amxbans for the steamid but i guess you already knew that

Code:
SELECT somefield, cast(mid(player_id,9,1)  as unsigned) + cast('76561197960265728' as unsigned) + cast(mid(player_id, 11,10)*2 as unsigned) AS comid, somefield FROM sometable
__________________
Gizmo is offline
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 02-25-2009 , 04:17   Re: Convert STEAMID to Steam Community ID
Reply With Quote #138

Thanks for the help but is it not possible without an extra query something like this for example.

PHP Code:
$communityid "cast(mid($player_id,9,1)  as unsigned) + cast('76561197960265728' as unsigned) + cast(mid($player_id, 11,10)*2 as unsigned)"
The above line doesn't work but maybe with a changement it can?
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.
Maurice is offline
Gizmo
Senior Member
Join Date: May 2006
Location: Sweden
Old 02-25-2009 , 05:22   Re: Convert STEAMID to Steam Community ID
Reply With Quote #139

What i wrote will work, add it in all querys were you get player_id like i wrote above and the parse comid to the template for bandetailes and use comid do do a link of the steamid like this
Code:
<td height='16' width='70%' class='listtable_1'>{if $ban_info.player_id == "&nbsp;"}<i><font color='#677882'>{"_NOSTEAMID"|lang}</font></i>{else}<a href=http://steamcommunity.com/profiles/".$ban_info.comid." target=_blank>{$ban_info.player_id}</a>{/if}</td>
__________________
Gizmo is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 02-25-2009 , 16:57   Re: Convert STEAMID to Steam Community ID
Reply With Quote #140

Quote:
Originally Posted by Gizmo View Post
Add this in the amxbans query and make a link of the steamid with the comid, i hope you know what i mean, im not to good in explaning, player_id is the field in amxbans for the steamid but i guess you already knew that

Code:
SELECT somefield, cast(mid(player_id,9,1)  as unsigned) + cast('76561197960265728' as unsigned) + cast(mid(player_id, 11,10)*2 as unsigned) AS comid, somefield FROM sometable
Why would yo do that when I just gave you a nice stored procedure to do it
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull 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 19:33.


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