NS2 Steamid to "real" Steamid

devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
edited February 2012 in Modding
NS2 outputs SteamID's in a weird format, it doesn't use the standard STEAM_0:x:y format, nor does it use the uint64 version of (which can be trivially converted back). What it does seem to give us is the m_unAccountId segment of the id. Happily, this can be <a href="http://hg.opensteamworks.org/open-steamworks/src/3761c6ead02e/Open%20Steamworks/CSteamID.h#cl-373" target="_blank">trivially converted</a> back to a normal steamid.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->            steamid = int(ns2steamid)
            if steamid % 2 == 0:
                steamid = "STEAM_0:0:%i" % (steamid/2)
            else:
                steamid = "STEAM_0:1:%i" % (steamid/2)<!--c2--></div><!--ec2-->

Comments

  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Thanks for that, I had wondered what output it was giving me.

    Is there a reason that NS2 ouputs in this format?
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    edited February 2012
    I'd guess they just figured it was unique enough, and didn't bother using either of the conversion options the CSteamID class provides. It's pretty weird though.

    Edit: Oops, I had the logic backwards, fixed now.
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    <!--quoteo(post=1823503:date=Jan 12 2011, 04:03 AM:name=player)--><div class='quotetop'>QUOTE (player @ Jan 12 2011, 04:03 AM) <a href="index.php?act=findpost&pid=1823503"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->For those interested, it concerns the 'GetUserId'-method of the 'ServerClient'-object. It returns an integer (a double actually, as all numbers are floating points in Lua) that contains the digested form of the classic SteamID format, which can be computed like so: STEAM_0:n:x -> 2x+n. So if we have STEAM_0:1:12345678, the SteamID-number returned by the 'GetUserId'-method will be 2*12345678+1 = 24691357.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Slow-poke.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1900091:date=Feb 6 2012, 01:19 AM:name=player)--><div class='quotetop'>QUOTE (player @ Feb 6 2012, 01:19 AM) <a href="index.php?act=findpost&pid=1900091"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Slow-poke.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Huh, if that's the case then you really can't convert back to a normal steamid. That would suck.
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    The 'n' (the auth-server ID) in STEAM_0:n:x is either 0 or 1, so you can deduce it by looking at whether the digested-id is even (n = 0) or odd (n = 1).
  • halfofaheavenhalfofaheaven Join Date: 2012-11-09 Member: 168660Members, Reinforced - Supporter, Reinforced - Gold
    So basically I need a PhD to convert a Steam ID? I don't get it. Is there any easier way for dumb people like me?
  • turtsmcgurtturtsmcgurt Join Date: 2012-11-01 Member: 165456Members, Reinforced - Supporter
    ns2tosteamid.com

    prime real estate.
  • jfmherokillerjfmherokiller Join Date: 2012-12-18 Member: 175408Members
    edited April 2013
    if anyone wants a pretty program/gui interface that allows you to convert 1 id at a time I can provide the link to it on my dropbox. it only does steam to ns2 thought.
  • TharosTharos Join Date: 2012-12-18 Member: 175439Members
    Use this to convert steam ID to ns2 steam id : ideone.com/k0OLF

    The ns2 wiki provide this information too : wiki.unknownworlds.com/ns2/Dedicated_Server#SteamID_Format
  • lwflwf Join Date: 2006-11-03 Member: 58311Members, Constellation
    I threw this together last week. Maybe someone else finds it useful.

    http://steamid.org/
Sign In or Register to comment.