Results 1 to 3 of 3

Thread: SayCurrentLevels

  1. #1
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default SayCurrentLevels

    Please don't eat me alive

    SCAR Code:
    Procedure SayCurrentLevels(Which: String);
    Var
      I: Integer;
      StrArr : TStringArray;
    Begin
      If LoggedIn <> True Then Exit;
      StrArr := ['', 'attack', 'strength', 'defence', 'range', 'prayer', 'magic', 'runecrafting',
        'hitpoints', 'agility', 'herblore', 'thieving', 'crafting', 'fletching', 'slayer',
        'mining', 'smithing', 'fishing', 'cooking', 'firemaking', 'woodcutting', 'farming',
        'construction', 'hunting', 'summoning'];
      For I := 0 to High(StrArr) Do
      If LowerCase(Which) = StrArr[I] Then
        Break
      Else
        srl_Warn('SayCurrentLevels', '"' + Which[I] + ' " is not a valid level', 0);    
      If I < 1 Then Exit;
      Try
        Players[CurrentPlayer].Level[I] := GetSkillInfo(Which, False);
      Except End;
      TypeSend(IntToStr(Players[CurrentPlayer].Level[I]));
    End;

    Added 3 more skills..
    Last edited by Naum; 08-07-2009 at 07:19 PM.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Won't this throw up a warn every time it is ran if "Which" isn't the first occurrence in "StrArr"? Also, this only says one level, so the function name probably shouldn't be plural. Furthermore, do you account at all for the user typing in something not recognized by the function and therefore out of the index bounds for the "Level" array?
    :-)

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    1st question, good point added.

    2nd question, I have that covered. Added a try block

    Also the title is straight from SRL.

    Furthermore, thank-you very much for telling me how to improve. Rep+
    Last edited by Naum; 06-29-2009 at 02:21 AM.

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
  •