Hey there. I have the following C# code set up on my button to convert SteamID to communityID, and vice versa. I recently tried to add the ability to input custom profile IDs, but this new code now hangs (xml section), and seems to return nothing. Anyone got any help?
[code]
private void btnConvertComm_Click(object sender, EventArgs e)
{
if (textEnterComm.Text.StartsWith("7"))
{
try
{
Int64 communityId = Int64.Parse(textEnterComm.Text);
string sub1 = textEnterComm.Text.Substring(textEnterComm.Text.Length - 1);
int sub11 = int.Parse(sub1);
if (sub11.Equals(0) || sub11.Equals(2) || sub11.Equals(4) || sub11.Equals(6) || sub11.Equals(8))
{
int authServer = 0;
CommunityToSteam(communityId, authServer);
}
else
{
int authServer = 1;
CommunityToSteam(communityId, authServer);
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
lblSteamOutput.Text = "Invalid Community ID";
}
}
else if (textEnterComm.Text != "")
{
string URLString = "http://steamcommunity.com/id/" + textEnterComm.Text + "?xml=1";
try
{
XmlTextReader reader = new XmlTextReader(URLString);
string sName = "";
string SteamID64 = "";
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
sName = reader.Name;
break;
case XmlNodeType.Text:
switch (sName)
{
case "steamID64":
SteamID64 = reader.Value;
break;
}
break;
label5.Text = SteamID64;
}
try
{
Int64 communityId = Int64.Parse(SteamID64);
string sub1 = textEnterComm.Text.Substring(textEnterComm.Text.Length - 1);
int sub11 = int.Parse(sub1);
if (sub11.Equals(0) || sub11.Equals(2) || sub11.Equals(4) || sub11.Equals(6) || sub11.Equals(8))
{
int authServer = 0;
CommunityToSteam(communityId, authServer);
}
else
{
int authServer = 1;
CommunityToSteam(communityId, authServer);
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
lblSteamOutput.Text = "Invalid Community ID";
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
else
{
lblSteamOutput.Text = "No Community ID entered";
}
if (textEnterSteamID.Text != "")
{
try
{
String authServer = textEnterSteamID.Text.Substring(8, 1);
String mainId = textEnterSteamID.Text.Substring(10);
SteamToCommunity(textEnterSteamID.Text.Substring(8, 1), textEnterSteamID.Text.Substring(10), Int64.Parse(authServer), Int64.Parse(mainId));
}
catch (Exception)
{
lblCommID.Text = "Invalid SteamID";
}
}
else
{
lblCommID.Text = "No SteamID entered";
}
}
[/code]
Pastebin link: [url]http://pastebin.com/gvJyQ6xs[/url]
SteamToCommunity and CommunityToSteam:
[code]
void SteamToCommunity(string authServer, string mainId, Int64 aus, Int64 mid)
{
try
{
if (textEnterSteamID.Text != String.Empty)
{
Int64 b = 76561197960265728;
Int64 b2 = b + aus;
Int64 mid2 = mid * 2;
Int64 final = b2 + mid2;
lblCommID.Text = final.ToString();
}
}
catch (Exception)
{
lblCommID.Text = "Invalid SteamID";
}
}
void CommunityToSteam(Int64 communityId, int authServer)
{
try
{
if (textEnterComm.Text != String.Empty)
{
Int64 p1 = communityId - 76561197960265728 - authServer;
Int64 p2 = p1 / 2;
string final = "STEAM_0:" + authServer.ToString() + ":" + p2.ToString();
lblSteamOutput.Text = final;
}
}
catch (Exception)
{
// MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
lblSteamOutput.Text = "Invalid Community ID";
}
}
[/code]
Pastebin link: [url]http://pastebin.com/DckPgW6f[/url]
Don't go to the URL. Just use the formulers
I'm using the formulas for converting SteamID to Community ID, and vice versa, but there is no "formula" to convert custom ID to SteamID... The only way to do such a thing, as far as I know, is to access that user's XML feed, and grab the "steamID64" element.
Sorry, you need to Log In to post a reply to this thread.