SRL Archive - SRL Archives

SayCurrentLevels


Naum

2009-06-28 21:41:58

Please don't eat me alive :)

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..

Method

2009-06-28 21:47:30

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?

Naum

2009-06-28 22:04:59

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+