Results 1 to 18 of 18

Thread: useful and funny function [ GetMyExperience ]

  1. #1
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default useful and funny function [ GetMyExperience ]

    This function download experience from runescape highscores.

    SCAR Code:
    {*******************************************************************************
    function GetMyExperience(myNumber: integer; myName: string): Integer;
    By: manfromczech
    Description: Downloads Rank/Level/Exp/Score from Runescape Highscores
    ********************************************************************************
                                   myNumber :=

    Skill name      |  Rank  |  Level  |   Xp    Game name           | Rank | Score
                                                 Duel Tournament     |  75  |  76
    Overall         |   0    |   1     |   2     Bounty Hunters      |  77  |  78
    Attack          |   3    |   4     |   5     Bounty Hunter Rogues|  79  |  80
    Defence         |   6    |   7     |   8     Fist of Gutix       |  81  |  82
    Strength        |   9    |   10    |   11
    Hitpoints       |   12   |   13    |   14
    Ranged          |   15   |   16    |   17
    Prayer          |   18   |   19    |   20
    Magic           |   21   |   22    |   23
    Cooking         |   24   |   25    |   26
    Woodcutting     |   27   |   28    |   29
    Fletching       |   30   |   31    |   32
    Fishing         |   33   |   34    |   35
    Firemaking      |   36   |   37    |   38
    Crafting        |   39   |   40    |   41
    Smithing        |   42   |   43    |   44
    Mining          |   45   |   46    |   47
    Herblore        |   48   |   49    |   50
    Agility         |   51   |   52    |   53
    Thieving        |   54   |   55    |   56
    Slayer          |   57   |   58    |   59
    Farming         |   60   |   61    |   62
    Runecraft       |   63   |   64    |   65
    Hunter          |   66   |   67    |   68
    Construction    |   69   |   70    |   71
    Summoning       |   72   |   73    |   74
    *******************************************************************************}

     
    function GetMyExperience(myNumber: integer; myName: string): Integer;
    begin
      Result := GetExperience(myNumber, myName);
    end;

    and source of dll plugin:

    Code:
    library GetMyExperience;
    
    
    uses
      FastShareMem,
      SysUtils,
      Classes,
      Windows,
      IdHttp,
      Graphics;
    
    {$R *.res}
    
    
    type
      TStrArray = array of string;
    
    
    function Explode(var a: TStrArray; Border, S: string): Integer;
    var
      S2: string;
    begin
      Result  := 0;
      S2 := S + Border;
      repeat
        SetLength(A, Length(A) + 1);
        a[Result] := Copy(S2, 0,Pos(Border, S2) - 1);
        Delete(S2, 1, Length(a[Result] + Border));
        Inc(Result);
      until S2 = '';
    end;
    
    
    function GetExperience(myNumber: integer; myName: string): integer; stdcall;
    var
      s: string;
      A: TStrArray;
      b: integer;
    begin
      b := myNumber;
      with TIdHttp.Create(nil) do
        try
          s := Get('http://hiscore.runescape.com/index_lite.ws?player=' + myName);
          s := StringReplace(s, '-1', '0', [rfReplaceAll]);
          s := StringReplace(s, #10, ',', [rfReplaceAll]);
        finally
        Explode(A, ',', s);
        result := StrToInt(A[b]);
        Free;
      end;
    end;
    
    
    function GetFunctionCount(): Integer; stdcall; export;
    begin
      Result := 1;
    end;
    
    
    function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
    begin
      case x of
        0:
          begin
            ProcAddr := @GetExperience;
            StrPCopy(ProcDef, 'function GetExperience(myNumber: integer; myName: string): integer;');
          end;
      else
        x := -1;
      end;
      Result := x;
    end;
    
    
    exports GetFunctionCount;
    exports GetFunctionInfo;
    
    
    end.
    I think this should be added to next rev
    What do you think about this function??
    :P

  2. #2
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Why make a plugin when you can write it in SCAR?

  3. #3
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    - when i use plugin, i don't need to allow conection with internet
    - i dont know if are in scar functions like StringReplace
    :P

  4. #4
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    StringReplace() is Replace().

  5. #5
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    but i still need to allow conection
    :P

  6. #6
    Join Date
    Sep 2006
    Location
    include srl/srl.scar ( aussie)
    Posts
    2,875
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Devs dont commit anything that conects to the runescape website, i think..

  7. #7
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by manfromczech View Post
    but i still need to allow conection
    This would have a way better chance of getting committed if it was in a SCAR script. I would be surprised if the Devs committed a plugin with one function it...


  8. #8
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Another reason why in plugin: i don't want to show everybody how it works.

    scar only:

    SCAR Code:
    program new;

    {*******************************************************************************
    function Explode(var a: TStrArray; Border, S: string): Integer;
    By: manfromczech
    Description: Used at GetExperience(...);
    *******************************************************************************}

    {*******************************************************************************
    function GetExperience(myNumber: integer; myName: string): Integer;
    By: manfromczech
    Description: Downloads Rank/Level/Exp/Score from Runescape Highscores
    ********************************************************************************
                                   myNumber :=

    Skill name      |  Rank  |  Level  |   Xp    Game name           | Rank | Score
                                                 Duel Tournament     |  75  |  76
    Overall         |   0    |   1     |   2     Bounty Hunters      |  77  |  78
    Attack          |   3    |   4     |   5     Bounty Hunter Rogues|  79  |  80
    Defence         |   6    |   7     |   8     Fist of Gutix       |  81  |  82
    Strength        |   9    |   10    |   11
    Hitpoints       |   12   |   13    |   14
    Ranged          |   15   |   16    |   17
    Prayer          |   18   |   19    |   20
    Magic           |   21   |   22    |   23
    Cooking         |   24   |   25    |   26
    Woodcutting     |   27   |   28    |   29
    Fletching       |   30   |   31    |   32
    Fishing         |   33   |   34    |   35
    Firemaking      |   36   |   37    |   38
    Crafting        |   39   |   40    |   41
    Smithing        |   42   |   43    |   44
    Mining          |   45   |   46    |   47
    Herblore        |   48   |   49    |   50
    Agility         |   51   |   52    |   53
    Thieving        |   54   |   55    |   56
    Slayer          |   57   |   58    |   59
    Farming         |   60   |   61    |   62
    Runecraft       |   63   |   64    |   65
    Hunter          |   66   |   67    |   68
    Construction    |   69   |   70    |   71
    Summoning       |   72   |   73    |   74
    *******************************************************************************}

    type
      TStrArray = array of string;


    function Explode(var a: TStrArray; Border, S: string): Integer;
    var
      S2: string;
    begin
      Result  := 0;
      S2 := S + Border;
      repeat
        SetLength(A, Length(A) + 1);
        a[Result] := Copy(S2, 0,Pos(Border, S2) - 1);
        Delete(S2, 1, Length(a[Result] + Border));
        Inc(Result);
      until S2 = '';
    end;


    function GetExperience(myNumber: integer; myName: string): integer;
    var
      s: string;
      A: TStrArray;
      b: integer;
    begin
      b := myNumber;
      try
        s := GetPage('http://hiscore.runescape.com/index_lite.ws?player=' + myName);
        s := Replace(s, '-1', '0');
        s := Replace(s, #10, ',');
      finally
      Explode(A, ',', s);
      result := StrToInt(A[b]);
      end;
    end;


    begin
      WriteLn(IntToStr(GetExperience(59, 'zezima')));
    end.
    :P

  9. #9
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by manfromczech View Post
    Another reason why in plugin: i don't want to show everybody how it works.
    It's not like it's terribly advanced or top-secret. This would just prevent people from learning from it, which is sort of backwards.

  10. #10
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by A G E N T View Post
    It's not like it's terribly advanced or top-secret. This would just prevent people from learning from it, which is sort of backwards.
    Maybe you're right.
    :P

  11. #11
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Also, using two explode functions would be more efficient

    Mine:

    SCAR Code:
    function HSGet(Username, Skill: string; Options : TStringArray) : TStringArray;

    var
      I, II, III, L : Integer;
      S : String;
      arrS : TStringArray;
      arrarrS : Array of TStringArray;

    begin
      try
        S := GetPage('http://hiscore.runescape.com/index_lite.ws?player=' + Replace(UserName, ' ', '_'))
      except
        Result := ['N/A', 'N/A', 'N/A']
        Exit;
      end;
      arrS := Explode(#10, S);

      SetArrayLength(arrarrS, 29);
      for I := 0 to 28 do
        arrarrS[I] := Explode(',', ArrS[I]);
      case LowerCase(Skill) of
        'overall'     : I := 0;
        'attack'      : I := 1;
        'defence'     : I := 2;
        'strength'    : I := 3;
        'hitpoints'   : I := 4;
        'ranged'      : I := 5;
        'prayer'      : I := 6;
        'magic'       : I := 7;
        'cooking'     : I := 8;
        'woodcutting' : I := 9;
        'fletching'   : I := 10;
        'fishing'     : I := 11;
        'firemaking'  : I := 12;
        'crafting'    : I := 13;
        'smithing'    : I := 14;
        'mining'      : I := 15;
        'herblore'    : I := 16;
        'agility'     : I := 17;
        'thieving'    : I := 18;
        'slayer'      : I := 19;
        'farming'     : I := 20;
        'runecraft'   : I := 21;
        'hunter'      : I := 22;
        'construction': I := 23;
        'summoning'   : I := 24;

        'duel_tournament'       : I := 25;
        'bounty_hunters'        : I := 26;
        'bounty_hunters_rougue' : I := 27;
        'fist_of_guthix'        : I := 28;
        else
        begin
          Notice(C.Nick, 'Invalid Skill inputted.');
          Exit;
        end;
      end;

      for III := 0 to High(Options) do
      begin
        case LowerCase(Options[III]) of
          'rank' : II := 0;
          'level', 'lvl', 'score' : II := 1;
          'xp' : II := 2;
          else II := -1;
        end;
        if II <> -1 then
        begin
          L := Length(Result);
          SetArrayLength(Result, L + 1);
          Result[L] := arrarrS[I][II];
          if Result[L] = '-1' then
            Result[L] := 'N/A';
        end;
      end;
    end;

    This returns a StringArray of what options you ask for in the Options Parameter.

    It just breaks apart strings and filters through them
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  12. #12
    Join Date
    Oct 2006
    Posts
    2,297
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    This is just useless for autoing, so shouldn't get in the SRL libary..

    -Tsn.
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  13. #13
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by the scar noob View Post
    This is just useless for autoing, so shouldn't get in the SRL libary..

    -Tsn.
    If it's useless why in SRL library is ConvertXpToLvl function??
    :P

  14. #14
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by manfromczech View Post
    If it's useless why in SRL library is ConvertXpToLvl function??
    because ppl can use that to determine what lvl they are andto see if they can already use a certain object or not.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  15. #15
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    This could be useful in fighting scripts to get the amount of damage dealt.

  16. #16
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    And in Pvp worlds to get someone else def/att/str level.
    :P

  17. #17
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Closed source code, or connection code that evades asking for permission will not be put into SRL, a function that connects to a site might have a chance of getting into the Misc folder, and it's usefulness must be high for that to happen.

    This could be useful in fighting scripts to get the amount of damage dealt.
    So instead of doing GetTextAtEx, you recommend getting the info from a website which takes several seconds?

  18. #18
    Join Date
    Dec 2007
    Posts
    2,766
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default

    N3s, you're right, it would be stupid .

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Funny as..
    By OmgThatOne in forum Music, Movies and TV
    Replies: 3
    Last Post: 05-24-2008, 12:18 AM
  2. Fun/Funny
    By A G E N T in forum Misc. Links and Programs
    Replies: 0
    Last Post: 06-27-2007, 03:02 PM
  3. lol thats funny
    By Dark_Sniper in forum RS has been updated.
    Replies: 7
    Last Post: 05-01-2007, 03:01 PM
  4. funny
    By Hey321 in forum Misc. Links and Programs
    Replies: 0
    Last Post: 11-13-2006, 01:59 AM
  5. sry this is just funny
    By Portal in forum News and General
    Replies: 7
    Last Post: 05-18-2006, 02:11 AM

Posting Permissions

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