SRL Archive - SRL Archives

SayCurrentLevels();


Gu3st...

2008-11-12 12:31:37

procedure SayCurrentLevels(which: string);
var
I: Integer;
begin
case LowerCase(Which) of
'attack': I := 1;
'strength': I := 2;
'defence': I := 3;
'range': I := 4;
'prayer': I := 5;
'magic': I := 6;
'runecrafting': I := 7;
'hitpoints': I := 8;
'agility': I := 9;
'herblore': I := 10;
'thieving': I := 11;
'crafting': I := 12;
'fletching': I := 13;
'slayer': I := 14;
'mining': I := 15;
'smithing': I := 16;
'fishing': I := 17;
'cooking': I := 18;
'firemaking': I := 19;
'woodcutting': I := 20;
'farming': I := 21;
end;
Players[CurrentPlayer].Level[i] := GetSkillInfo(which,False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
end;
Maybe better like this:
procedure SayCurrentLevels(which: string);
var
I: Integer;
begin
case LowerCase(Which) of
'attack': I := 1;
'strength': I := 2;
'defence': I := 3;
'range': I := 4;
'prayer': I := 5;
'magic': I := 6;
'runecrafting': I := 7;
'hitpoints': I := 8;
'agility': I := 9;
'herblore': I := 10;
'thieving': I := 11;
'crafting': I := 12;
'fletching': I := 13;
'slayer': I := 14;
'mining': I := 15;
'smithing': I := 16;
'fishing': I := 17;
'cooking': I := 18;
'firemaking': I := 19;
'woodcutting': I := 20;
'farming': I := 21;
else
srl_Warn('SayCurrentLevels', ' Not a valid level.', -1);
end;
Players[CurrentPlayer].Level[i] := GetSkillInfo(which,False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
end;

EvilChicken!

2008-11-16 09:27:12

First of all, -1 is warn_Terminate. Hence, the script would be terminated if this small error was to be done. And, you forgot to exit out of the procedure if the level string wasn't correct. Otherwise thanks, this is the version I committed:

{*******************************************************************************
procedure SayCurrentLevels(which: String);
By: RealRune
Description: Very useful for autoresponders.
*******************************************************************************}
procedure SayCurrentLevels(Which: string);
var
I: Integer;
begin
if not LoggedIn then exit;
I := 0;
case LowerCase(Which) of
'attack': I := 1;
'strength': I := 2;
'defence': I := 3;
'range': I := 4;
'prayer': I := 5;
'magic': I := 6;
'runecrafting': I := 7;
'hitpoints': I := 8;
'agility': I := 9;
'herblore': I := 10;
'thieving': I := 11;
'crafting': I := 12;
'fletching': I := 13;
'slayer': I := 14;
'mining': I := 15;
'smithing': I := 16;
'fishing': I := 17;
'cooking': I := 18;
'firemaking': I := 19;
'woodcutting': I := 20;
'farming': I := 21;
else
srl_Warn('SayCurrentLevels', '"' + which + ' " is not a valid level', 0);
end;
if I < 1 then exit;
Players[CurrentPlayer].Level[i] := GetSkillInfo(which,False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
end;

Edit: My first commit, by the way :)

MylesMadness

2008-11-16 09:34:32

procedure SayCurrentLevels(Which: string);
var
I: Integer;
begin
if not LoggedIn then exit;
I := 0;
case LowerCase(Which) of
'attack': I := 1;
'strength': I := 2;
'defence': I := 3;
'range': I := 4;
'prayer': I := 5;
'magic': I := 6;
'runecrafting': I := 7;
'hitpoints': I := 8;
'agility': I := 9;
'herblore': I := 10;
'thieving': I := 11;
'crafting': I := 12;
'fletching': I := 13;
'slayer': I := 14;
'mining': I := 15;
'smithing': I := 16;
'fishing': I := 17;
'cooking': I := 18;
'firemaking': I := 19;
'woodcutting': I := 20;
'farming': I := 21;
else
srl_Warn('SayCurrentLevels', '"' + which + ' " is not a valid level', 0);
end;
if I < 1 then exit;
if Players[CurrentPlayer].Level[i] = 0 then
Players[CurrentPlayer].Level[i] := GetSkillInfo(which,False);
TypeSend(IntToStr(Players[CurrentPlayer].Level[i]));
end;

I see that if you leveled it could be a problem, but at least it would be close, and it wouldn't waste time going to the skills tab

EvilChicken!

2008-11-16 10:24:46

Actually, I thought about your idea, Myles.

Though, I'm not really sure about whether to commit that or not, hopefully some other dev who has clearer opinions on this, (although this isn't a commonly used nor important procedure) says his opinion on this.

Bobarkinator

2008-11-16 13:42:36

Some people use CurrentPlayer.Level as part of their script. You should probably store the level in a different variable

MylesMadness

2008-11-17 18:40:45

From: Bobarkinator
Some people use CurrentPlayer.Level as part of their script. You should probably store the level in a different variable
Use it for something else other than levels? Thats dumb…

Bobarkinator

2008-11-17 21:09:39

From: Mylesmadness
Use it for something else other than levels? Thats dumb…


I've seen it before.

MylesMadness

2008-11-18 15:11:09

From: Bobarkinator
I've seen it before.
Why wouldn't they use Player.Integers[0]?

Bobarkinator

2008-11-18 22:08:34

From: Mylesmadness
Why wouldn't they use Player.Integers[0]?



I'm not saying I condone it, just saying I've seen it before. It would be better to just return the level and let the user store it in whatever variable they wish.

Gu3st...

2008-11-19 17:04:31

Woah, so many post just because I wanted a srl_Warn() in it O.o
Don't make this a flame thread ppl.. :)