SteamID&CommunityID Functions [VB .Net]

Forum rules
- Ask questions about or share code from languages other than Source Engine scripting.
- Start new topic titles with the code language in brackets (i.e. [C#], [C++], [PHP], etc.)
Locked
User avatar
Blake
500+ Posts
500+ Posts
Posts: 588
Joined: Mon Jul 05, 2010 8:51 pm
Location: Ontario, Canada

SteamID&CommunityID Functions [VB .Net]

Post by Blake » Sat May 14, 2011 11:03 pm

Read Steam Community XML

Code: Select all

    Public Class SteamIDInfo
        Public Function GetSteamIDInfo(ByVal Type As String, ByVal ID As String, ByVal Element As String)
            If String.IsNullOrEmpty(ID) Then
                Return Nothing
            End If
            Dim reqUrl As String = "http://steamcommunity.com/" + Type + "/" + ID + "/?xml=1"
            Dim httpReq As HttpWebRequest = TryCast(HttpWebRequest.Create(reqUrl), HttpWebRequest)
            Try
                Dim result As String = String.Empty
                Dim response As HttpWebResponse = TryCast(httpReq.GetResponse(), HttpWebResponse)
                Using reader = New StreamReader(response.GetResponseStream())
                    result = reader.ReadToEnd()
                End Using
                Return ProcessResponse(result, Element)
            Catch ex As Exception
                Throw
            End Try
        End Function

        Private Function ProcessResponse(ByVal strResp As String, ByVal TheElement As String)
            Dim Result As String = Nothing
            Dim sr As New StringReader(strResp)
            Dim respElement As XElement = XElement.Load(sr)
            Dim tmpEle As String = respElement.Element(TheElement)
            Return tmpEle
        End Function
    End Class
SteamID To CommunityID & CommunityID To SteamID

Code: Select all

    Private Shared intBigNum As Long = 76561197960265728

    Private Function GetCommunityId(ByVal pSteamId As String) As String
        pSteamId = Trim(pSteamId)
        pSteamId = UCase(pSteamId)
        Dim strRegEx As String = "\bSTEAM_[0-1]:[0-1]:(\d+)\b"
        If RegularExpressions.Regex.IsMatch(pSteamId, strRegEx) Then
            pSteamId = pSteamId.Substring(6)
            Dim arrParts() As String = pSteamId.Split(":")
            Dim intAuthSvr1 As Integer = arrParts(0)
            Dim intAuthSvr2 As Integer = arrParts(1)
            Dim intClientNum As Long = arrParts(2)
            Return CType(intBigNum + intAuthSvr2 + (intClientNum * 2), String)
        Else
            Return CStr(0)
        End If
    End Function

    Private Function GetSteamId(ByVal pCommunityId As String) As String
        If pCommunityId.Length = 17 And IsNumeric(pCommunityId) = True Then
            Dim intCommunityId As Long = CType(pCommunityId, Long)
            Dim intAuthSvr1 As Integer = 0
            Dim intAuthSvr2 As Integer = Nothing
            If intCommunityId Mod 2 Then
                intAuthSvr2 = 1
            Else
                intAuthSvr2 = 0
            End If
            Dim intClientNum As Long = (intCommunityId - intBigNum - intAuthSvr2) / 2
            Return "STEAM_" & CStr(intAuthSvr1) & ":" & CStr(intAuthSvr2) & ":" & CStr(intClientNum)
        Else
            Return CStr(0)
        End If
    End Function
Unkown wrote: Life’s too short to worry about the little things.
Albert Einstein wrote: You do not really understand something unless you can explain it to your grandmother.

User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: SteamID&CommunityID Functions [VB .Net]

Post by killman2639 » Wed May 02, 2012 11:15 pm

Well done smacked.
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.

User avatar
ant_8490
Site Admin
Posts: 4384
Joined: Fri Apr 09, 2010 3:20 pm
Location: United States
Contact:

Re: SteamID&CommunityID Functions [VB .Net]

Post by ant_8490 » Thu May 03, 2012 6:56 am

killman2639 wrote:Well done smacked.
Almost 1 year later.
[GR]Ant_8490{A}
Area 51 Servers - Owner
Image
Image
Image
Image

MSI GE76 Raider
i9-11980HK 2.6GHz 8-Core Processor
32GB 3200Mhz DDR4 RAM
NVIDIA GeForce RTX 3080 Laptop GPU 16GB
2TB Samsung 980 Pro SSD
Windows 10

Ryan
Former Server Admin
Posts: 1163
Joined: Fri Apr 23, 2010 2:56 am
Location: United Kingdom

Re: SteamID&CommunityID Functions [VB .Net]

Post by Ryan » Thu May 03, 2012 2:02 pm

ant_8490 wrote:
killman2639 wrote:Well done smacked.
Almost 1 year later.
12 days out. Seems too coincidental.

User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: SteamID&CommunityID Functions [VB .Net]

Post by killman2639 » Thu May 03, 2012 9:56 pm

Yeah I know it's old, lol. I was going through the old stuff and found this and accidentally pressed a button, bump I belive, don't remember exactly, that apparently "reactivates" the topic. :P
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.

Locked