Jump to content

Welcome to Rune Tips, the first ever RuneScape help site. We aim to offer skill guides, quest guides, maps, calculators, informative databases, tips, and much more to help you get the most from the Massive Online Adventure Game, RuneScape, by Jagex Ltd © 2009.

Report Ad

Welcome to Forum.Tip.It
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

Runescape API--.NET 4.0


  • Please log in to reply
12 replies to this topic

#1
geel9
[ Display Name History ]

geel9

    Chicken Feather

  • Members
  • 5 posts
  • Joined:1 August 2007
CURRENT VERSION: Development 0.5

Hi guys! I'm Geel9, obviously, and I've been working on a Runescape API for .NET 4.0. It will, eventually, have all the features that you need to make a sick Runescape application. This is not released yet!

Requirements:
Using .NET 4.0



Classes so far:
  • Main--This does nothing for the programmer.
  • Highscores--Used to get Highscore info
  • GERequest--Used to get item prices
  • AdvLog---used to get a player's Adventurer's Log







Highscores Documentation




List<string> getPlayerStats(string username)
This returns a List<string> of the player's stats on the highscores, organized as such:
rank,level,experience
So, using getPlayerStats("geel9"), we'd get this(each new line is a different index in the List<string>)

271359,1680,19892015
501891,80,1986588
356390,80,2049194
674117,81,2193428
524442,82,2535620
808048,71,862653
347988,62,343981
458023,78,1631821
511026,75,1229818
1199423,72,959218
1025156,61,307352
681006,70,776987
805021,62,341688
368200,64,407219
385690,63,370343
942282,64,408310
218843,61,305852
271077,62,348847
149865,69,670244
310833,66,498125
186129,63,371423
307348,55,174781
450877,59,261531
221601,60,279390
213971,63,368840
95647,57,208762
-1,-1
-1,-1
-1,-1
-1,-1
-1,-1
150386,738
-1,-1
251180,510
25954,2451
-1,-1
-1,-1

Note that after a certain point, they only have two commas per skill. Those aren't skills, those are minigames, and are formatted as:
rank,score

Here's a fully commented example of using the Highscores.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RSapi;

namespace APItest
{
    class APItest
    {
        static void Main(string[] args)
        {
            //Make the list to hold our highscores
            List<string> scores = new List<string>();
            //Get the username to find
            Console.WriteLine("What is your username?");
            string username = Console.ReadLine();
            //Get the scores, and output them.
            scores = RSapi.Highscores.getPlayerStats(username);
            //If the username is found
            if (scores.Count > 0)
            {
                foreach (string l in scores)
                {
                    Console.WriteLine(l);
                }
            }
            Console.ReadLine();

        }
    }
}



GERequest Documentation

The GERequest class is an instance-based class, or rather, it's not static. You need to create an instance of it first.

Here's how it works.

GERequest(string search)
The GErequest class is what you use to make a GE price search. It takes a string in its constructor and uses that as the search.
Example:
GERequest request = new GERequest("dragon longsword");


List<string> getItems()
Returns the list of items that the GERequest found.
Example:
List<string> list = new List<string>();
list = request.getItems();


List<string> getPrices()
Returns the list of prices that the GERequest found. Note that the prices are just prices; to get the item names, you must use the same index as the price. For example, to get the item name of prices[4], use items[4].


List<string> getChange()
Returns the change in price for each item the GERequest found.


string getFirstItem()
Returns the first item the GERequest found.

string getFirstPrice()
Returns the price for the first item the GERequest found.

string getFirstChange()
Returns the change in price today for the first item the GERequest found.



Example of GERequest:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RSapi;

namespace APItest
{
    class APItest
    {
        static void Main(string[] args)
        {
            //Make the lists for our items, prices and price changes
            List<string> items = new List<string>();
            List<string> prices = new List<string>();
            List<string> changes = new List<string>();
            //Get the search term
            Console.WriteLine("What would you like to search for?");
            string search = Console.ReadLine();
            //Make a new GERequest instance and pass the search term to it.
            GERequest request = new GERequest(search);
            //Get the items from the request
            items = request.getItems();
            //Get the prices
            prices = request.getPrices();
            //Get the change in prices
            changes = request.getChange();
            //Print it all out
            if (items.Count > 0)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    Console.WriteLine(items[i] + " cost(s) " + prices[i] + " and changed " + changes[i] + " today.");
                }
            }
            Console.ReadLine();
        }
    }
}




AdvLog


Nothing yet, working on it.

#2
Hegelstad
[ Display Name History ]

Hegelstad

    Varrock Guard

  • Members
  • 1,440 posts
  • Gender:Male
  • Location:Norway
  • Joined:11 April 2009
  • RuneScape Status:P2P
  • RSN:Hegelstad
  • Clan:Team Bring It
Epic, would be of very nice use!

My lame drops:
6 Effigys
1 D Med - 1 D Dagger
1 Verac's Helmet - 1 Guthan's Platebody


#3
geel9
[ Display Name History ]

geel9

    Chicken Feather

  • Members
  • 5 posts
  • Joined:1 August 2007

Epic, would be of very nice use!



Awesome, do you have any experience in C#?

#4
Hegelstad
[ Display Name History ]

Hegelstad

    Varrock Guard

  • Members
  • 1,440 posts
  • Gender:Male
  • Location:Norway
  • Joined:11 April 2009
  • RuneScape Status:P2P
  • RSN:Hegelstad
  • Clan:Team Bring It
Not too much ;-)

My lame drops:
6 Effigys
1 D Med - 1 D Dagger
1 Verac's Helmet - 1 Guthan's Platebody


#5
Orpheus
[ Display Name History ]

Orpheus

    Ice Giant Melter

  • Members
  • 4,783 posts
  • Gender:Male
  • Location:United Stat -TROMBE!
  • Joined:24 August 2006
  • RuneScape Status:None
Hmm, C# eh? I'm working with C++ right now so I couldn't quite help you yet, but best of luck with this.


I was going to eat hot dogs for dinner tonight. I think I will settle for cereal.


OPEN WIDE HERE COMES THE HELICOPTER.


#6
Delscid
[ Display Name History ]

Delscid

    Chicken Feather

  • Members
  • 23 posts
  • Gender:Male
  • Location:New Zealand
  • Joined:21 July 2008
  • RuneScape Status:P2P
  • RSN:Runecid
Looks good, could be useful for the runescape client im trying to build.

If you want any help with putting the results into a class structure instead of arrays and lists, I could try to throw something together for you?

e.g:
HighscoreResult result = RSapi.Highscores.getPlayerStats("username");
Console.WriteLine(result.Skills.Overall.Level);
instead of
List<string> result = RSapi.Highscores.getPlayerStats("username");
Console.WriteLine(result[0].split(',')[1]);



#7
geel9
[ Display Name History ]

geel9

    Chicken Feather

  • Members
  • 5 posts
  • Joined:1 August 2007
Haha, sorry, I already did. I just didn't update the first post ;) I'll work on making a wiki or something.

#8
Delscid
[ Display Name History ]

Delscid

    Chicken Feather

  • Members
  • 23 posts
  • Gender:Male
  • Location:New Zealand
  • Joined:21 July 2008
  • RuneScape Status:P2P
  • RSN:Runecid
ok, no problem

just an after-thought, you could use the adventurers log to check and fill in most blanks from the highscores, it would be a wasted request though if the person wasn't a member.


#9
geel9
[ Display Name History ]

geel9

    Chicken Feather

  • Members
  • 5 posts
  • Joined:1 August 2007
Interesting idea. Right now I'm working on threading the requests, so the entire application doesn't hang.

#10
GottaGetDownOnfriday
[ Display Name History ]

GottaGetDownOnfriday

    Bear Fur

  • Members
  • 264 posts
  • Joined:16 June 2010
This looks pretty decent. I don't really do anything Runescape related anymore. I mainly code in Java/C or C++
Posted Image

65,280 to 99 fletching on 3-14-09
40,405 to 99 woodcutting on 10-17-2009

#11
Ronan
[ Display Name History ]

Ronan

    Bear Fur

  • Members
  • 396 posts
  • Gender:Male
  • Location:Edinburgh - Scotland
  • Joined:28 October 2007
  • RuneScape Status:P2P
  • RSN:Ronan
Are you sure that it requires .NET 4? At first glance it doesn't seem to use any of the more recent features - although there's obviously more that you haven't shown.

You may also want to get rid of the Linq using directive, I know Express builds automatically stick that in but it doesn't look like you're using it.

Would be nice to have this released - save many people re-writing small utility classes to do exactly what this does. I'd contribute if you Open Source it. :)

#12
geel9
[ Display Name History ]

geel9

    Chicken Feather

  • Members
  • 5 posts
  • Joined:1 August 2007

Are you sure that it requires .NET 4? At first glance it doesn't seem to use any of the more recent features - although there's obviously more that you haven't shown.

You may also want to get rid of the Linq using directive, I know Express builds automatically stick that in but it doesn't look like you're using it.

Would be nice to have this released - save many people re-writing small utility classes to do exactly what this does. I'd contribute if you Open Source it. :)


System.Linq is only used in the examples, it's not in the API source.

#13
Mastermosley
[ Display Name History ]

Mastermosley

    Chicken Feather

  • Members
  • 17 posts
  • Gender:Male
  • Location:Nanaimo, BC Canada
  • Joined:10 May 2010
  • RuneScape Status:P2P
  • RSN:xblackslashx
This is what I used for the highscores lookup might help with your api. Taken from RS Regent Toolkit http://www.rsregent.net
WebClient stats = new WebClient();
                Stream statstream = stats.OpenRead("http://hiscore.runescape.com/index_lite.ws?player=" + RSN);
                StreamReader statread = new StreamReader(statstream);
                string sockread = null, sockline = null;
                int aa = 0;
                while ((sockread = statread.ReadLine()) != null)
                {
                    string[] bb = sockread.Split(new string[] { "," }, StringSplitOptions.None);
                    if (bb.Length == 3)
                    {
                        if (bb[0] != "-1")
                        {
                            int r = int.Parse(bb[0]), l = int.Parse(bb[1]), f = int.Parse(bb[2]);
                            string rank = String.Format("{0:0,0}", r), level = String.Format("{0:0,0}", l), exp = String.Format("{0:0,0}", e);
                            // sockline = SkillsArray[aa] + " " + "Rank: " + rank + " Level: " + level + " Exp: " + exp; aa++; Console.WriteLine(sockline);
                            hst[aa].Text = rank;
                            gst[aa].Text = level;
                            aa++;
                        }
                        else { aa++; }
                    }
                    else
                    {
                        if (bb[0] != "-1")
                        {
                            int r = int.Parse(bb[0]), l = int.Parse(bb[1]);
                            string rank = String.Format("{0:0,0}", r), level = String.Format("{0:0,0}", l);
                            // sockline = SkillsArray[aa] + " " + "Rank: " + rank + " Score: " + level; aa++; Console.WriteLine(sockline);
                            hst[aa].Text = rank;
                            gst[aa].Text = level;
                            aa++;
                        }
                        else { aa++; }
                    }

                }

                statstream.Close();
            }

        }

I have labels for Rank and Level Referenced in order hst = highscorestext, gst = level. Grabs the highscores lite data and splits it into separate strings and goes from there. Any questions I can probobly help you out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users