Results 1 to 12 of 12

Thread: [OSR] getPrice (GE) + updated stringToID

  1. #1
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default [OSR] getPrice (OSBUDDY) + updated stringToID

    getPrice

    @Sjoe; asked me to make this so here we go

    Simba Code:
    {author: Hoodz}

    type TItemInfo = record
      buy, sell, med: Integer;
    end;

    function StringToID(StringName: string): Integer;
    var
      I: Integer;
      S, Ls, Cs: string;
      SArray: TStringArray;
      Noted: Boolean;
    begin
      Noted := false;
      if (StringMatch('*', StringName) > 0) then
      begin
        Noted := true;
        StringName := Replace(StringName, '*', '', [rfReplaceAll])
      end;
      LS := Replace(StringName, ' ', '+', [rfReplaceAll]);
      S := GetPage('http://www.itemdb.biz/index.php?search=' + LS);
      Cs := Between('<div id="content">', '</font></', S);
      Cs := Between('<font color=''', '''>', Cs);
      if (Cs = 'red') then
      begin
        Writeln(StringName + ' Could not be found');
        Result := - 1;
        Exit;
      end;
      S := Between('<td><center><b>', StringName + '<', S);
      SArray := Explode('<b>', S);
      S := SArray[High(SArray)];
      SArray := Explode('</b>', S);
      S := SArray[0];
      if (S = '') then
      begin
        Writeln(StringName + ' Could not be found');
        Result := - 1;
        Exit;
      end;
      I := StrToInt(S);
      if (Noted) then
      begin
        Inc(I);
        Writeln('Item loaded: ' + StringName + ' (noted)  - ' + ' (' + IntToStr(I) + ')');
      end
      else
        Writeln('Item loaded: ' + StringName + '  - ' + ' (' + S + ')');
      Result := I;
    end;  

    function namesToIDs(StringArray: array of string): array of Integer;
    var
      I, IntReturn: Integer;
      IntArray: array of Integer;
    begin
      for I := 0 to High(StringArray) do
      begin
        IntReturn := StringToID(StringArray[I]);
        if (IntReturn = - 1) then
          continue;
        SetLength(IntArray, Length(IntArray) + 1);
        IntArray[High(IntArray)] := intReturn;
      end;
      Result := IntArray;
    end;

    function getPrice(itemName: String): TItemInfo;
    var
      itemID: Integer;
      webSource, buySource, sellSource, medSource: String;
    begin
      itemID := stringToID(itemName);
      if (itemID = -1) then
        exit;
      webSource := getPage('http://api.rsbuddy.com/grandExchange?a=guidePrice&i=' + toStr(itemID));
      buySource := between('"buying":', ',', webSource);
      sellSource := between('"selling":', ',', webSource);
      medSource := between('"overall":', ',', webSource);
      result.buy := strToInt(buySource);
      result.sell := strToInt(sellSource);
      result.med := strToInt(medSource);
      writeln('prices loaded (' + itemName + '): buy: ' + toStr(result.buy) + '  sell: ' + toStr(result.sell) + '  med: ' + toStr(result.med));
    end;

    usage:
    Simba Code:
    program example;

    {first declare a var for your item}
    var
      plateBody: TItemInfo;
      medPrice: Integer;


    begin
      {init the var}
      plateBody := getPrice('Rune platebody');

      {use your var like this}
      medPrice := plateBody.med;
    end.

    getPrice is a record which holds the following vars: sell, buy, med (medium)
    can be used with and without the AeroLib include from @Flight;

    NOTE: case sensitive!
    Last edited by Hoodz; 01-24-2016 at 12:56 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    repped+

    ty buddy

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Neato, I might add this to AL in the near future. Good job Hoodz.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  4. #4
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    repped+

    ty buddy
    thanks

    Quote Originally Posted by Flight View Post
    Neato, I might add this to AL in the near future. Good job Hoodz.
    thank you, I've got some more procedures/functions if you'd like that.

  5. #5
    Join Date
    Apr 2015
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice
    Can you add more ?

  6. #6
    Join Date
    Mar 2015
    Posts
    189
    Mentioned
    3 Post(s)
    Quoted
    73 Post(s)

    Default

    Thanks man I used some of your code to loop through all the items and see if there is a price lower than the alch price no luck yet

    Also made this one, if sombody needs it they can always use:

    Code:
    function getItemNameById(id : integer) : string; //Returns the Itemname (string) by inputting a id (integer) as a parameter
    var
      wikiaPage, priceString: string;
    begin
      wikiaPage := getPage('http://www.runelocus.com/item-details/?item_id=' + tostr(id));
      priceString := between('<h2>Information about ''', '''</h2>', wikiaPage);
      Result := priceString;
    end;

  7. #7
    Join Date
    Sep 2008
    Posts
    754
    Mentioned
    8 Post(s)
    Quoted
    275 Post(s)

    Default

    great job hoodz this looks awesome!
    Quit gaming

  8. #8
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by samerdl View Post
    great job hoodz this looks awesome!
    thank you bro!

  9. #9
    Join Date
    Oct 2011
    Location
    England
    Posts
    401
    Mentioned
    10 Post(s)
    Quoted
    176 Post(s)

    Default

    Thanks Hoodz, this might come in handy at some point
    Yer a wizard, 'oopi

  10. #10
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    @3Garrett3; would this not be the fix you were looking for? For your merchant aid?

  11. #11
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    @3Garrett3; would this not be the fix you were looking for? For your merchant aid?
    Not exactly. This snippet grabs OSRS prices and I'm looking for RS3. Also (although minimal) I need to grab IDs and Trade Limits as well in my function (which is also broken I think).

    Thanks for the mention though, I wish I could use this.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  12. #12
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    @3Garrett3; would this not be the fix you were looking for? For your merchant aid?
    Quote Originally Posted by 3Garrett3 View Post
    Not exactly. This snippet grabs OSRS prices and I'm looking for RS3. Also (although minimal) I need to grab IDs and Trade Limits as well in my function (which is also broken I think).

    Thanks for the mention though, I wish I could use this.
    this is a little bit outdated because its grabbing the osbuddy prices, osr got now their own GE site.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •