1 Replies - 974 Views - Last Post: 01 April 2013 - 07:19 AM Rate Topic: -----

#1 Rhaom   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 31-March 13

Storing data from a live web link in an array

Posted 01 April 2013 - 07:08 AM

I am very new to C# and while I was reading tutorials and doing basic challenges like making a calculator and such things, a friend asked me if i would make him a skill tracker for an online game he plays (runescape). So I know how to make arrays and how to use a web client to get the information I need. However what I don't know how to do is how to store that information in the background so the user cannot see it and it doesn't take a long time to load.

The company that owns the game provides the link "hiscore.runescape.com/index_lite.ws?player=" and you simply put the players username on the end of it. So lets say for example we are using "http://hiscore.runescape.com/index_lite.ws?player=Atomx"

The it will give me a whole load of integers

63355,2225,175843862 123933,97,11323502 78740,99,13569573 208118,90,5773939 99081,99,15286430 60389,99,13998728 158467,80,2017893 74555,99,13878210 116775,99,13093021 50492,99,14058758 78146,99,13117967 112367,90,5358717 115421,92,7129112 55704,90,5390427 54831,90,5390851 90385,85,3268592 120625,83,2734972 61828,85,3501486 137564,73,1005953 75732,88,4637504 31946,96,10007496 87524,85,3259026 125004,74,1149283 69862,80,1996811 84364,88,4389219 198349,66,506392 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1

Each of these numbers represents A Level, An amount of experience and a rank... basically a hiscore system.

As far as my code is concerned what I have right now is:

      string hslite;
            string rsuser;
            string lookup;

            hslite = "http://hiscore.runescape.com/index_lite.ws?player=";
            rsuser = txtUser.Text;
            lookup = hslite + rsuser;
            //txtStatSplit.Text = lookup;

                WebClient client = new WebClient();
                lookup = client.DownloadString(hslite + rsuser);
                txtStatSplit.Text = Convert.ToString(lookup);

            string[] hsArray = txtStatSplit.Text.Split(',', '\n');

            txtAttLvl.Text = (hsArray[4]);
            txtAttExp.Text = (hsArray[5]);
            //txtAttRank.Text = (hsArray[6]);
            txtDefLvl.Text = (hsArray[7]);
            txtDefExp.Text = (hsArray[8]);

This currently only shows 1 user at a time depending on what username you have put in the textbox and it also shows the stats being split (unless ofcourse you make txtStatSplit invisible, then it just takes forever to load if it loads at all!).

I don't want users to be able to see the stats being split and I also want them to be able to track more than 1 user at once on a specific skill.

Lets say for example with the long list of numbers displayed at the top that:

If you look 23 stats in (using , and spaces to split up the stats because "175843862 123935", is 2 values) then you get 99,13878210 116778.

These numbers say that this player has level 99 fletching, he has 13878210 total fletching exp and his overall rank in fletching is 116778.

I am looking for a way to store the information by skill name so that the user can put in 3 or 4 different users and be able to see all of their "fletching" stats at once, not just 1 user at a time

Sorry if this is a bit confusing, If a better explination is required i can provide it :)/>

Is This A Good Question/Topic? 0
  • +

Replies To: Storing data from a live web link in an array

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Storing data from a live web link in an array

Posted 01 April 2013 - 07:19 AM

To store the data without the user seeing it....
You need to use variables. Don't use GUI controls as your place to store these things. So you use a string property of 'Name', not txtBoxName.Text

The rest of this is all about design. To do the things you want to do you need to create classes. A PlayerObj for example could be the class that stores everything about the player. You then keep a List<PlayerObj> to track all the players and not just one.

There are tutorials listed in my signature block for classes and properties.

My standard beginner resources post - Updated JAN 2013

Plan your study route:
There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)

For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

  • First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover.
  • Do a dozen on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
  • Learn to plan before you type.
  • THEN you start designing software with a purpose.

I don't learn from reading books: I learn by doing.

Newbie/Rookie said:

I have little/no programming experience but I need to write a program by Friday that does XYZ.

Resources, references and suggestions for new programmers.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1