SRL Archive - SRL Archives

GetCurrentXp(skill: string)


marpis

2008-11-25 13:54:04


function GetCurrentXp(skill: string): integer;
var XP : string;
XPint, x, y: integer;
begin
try
HoverSkill(skill, false);
FindText(x, y, 'Current', SmallChars, MIX1, MIY1, MIX2, MIY2);
XP:= TrimLetters(TrimOthers(GetTextatex(x + 70, y, 0, SmallChars, False, False, 0, 3, 0, 15, True, tr_AllChars)));
writeln('Current xp in '+skill+' = '+XP);
XPint := strtoint(XP);
result := XpInt;
except
result := 0; //edited 26.11.2008!
writeln('Unable to get XP');
end;
end;
Couldn't have done this without the help of my man
Janilabo
:)

I think this is a very handy function in Progressionraports and should be added to SRL.

Method

2008-11-25 14:37:55

There is already one in SRL:

{*******************************************************************************
function GetXP(Skill: String): Integer;
By: Nielsie95
Description: Returns current xp for a skill. Returns -1 if failed.
*******************************************************************************}

function GetXp(skill: string): Integer;
var
p: TPoint;
i, tx, ty, x, y: Integer;
begin
Result := -1;
if (not LoggedIn) or (not TabExists(2)) then Exit;
GameTab(2);
if (GetCurrentTab <> 2) then Exit;
p := SkillToCoords(True,Skill);
if (p.x < 1) then Exit;
MMouse(p.x, p.y +5, 12, 4);
while (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) and (i < 50) do
begin
Wait(100);
Inc(i);
end;
Wait(200 + Random(150));
if (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) then Exit;
if IsTextInAreaEx(x, y, x + 60, y + 60, tx, ty, 'urrent', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;

marpis

2008-11-25 14:48:36

oh shit. i missed that -.-
…"#/"#%"#/(ยค/…

HarryJames

2008-11-25 17:53:58

lol?
maraizzos's looks shorter but is it less effective?

marpis

2008-11-26 05:04:31

I don't think its any less effective, because i think the try-except is just as good as failsafes like
if (not LoggedIn) or (not TabExists(2)) then Exit;
because anyway the result is the same: either it returns the value or not.
I must try this while being in some random event, like frogcave etc to see what happens. I suppose it just prints out 'unable to get xp'

EDIT: btw its marpis now ;)
EDIT: OH i got it now! The longer one is better, because if the getcurrentxp fails and returns no value, it might mess up all upcoming procedures that use the function. I think if i just add there if failed -> return := 0; its as good as the longer one.

jaykem

2009-04-06 10:46:31

hey guys im new and about this skill thing wheres the link and how are you susposto use it.

marpis

2009-04-06 10:52:00

From: jaykem
hey guys im new and about this skill thing wheres the link and how are you susposto use it.


I want to get current fishing xp:

var
i: integer;
begin
i:= GetXP('fishing');
writeln('Current Fishing XP: '+IntToStr(i));
end;

If you don't know anything about the code above, please read more beginner tutorials in the Tutorial Island-section.

Markus

2009-04-06 11:37:44

Gravedig, closed.