SRL Archive - SRL Archives

useful and funny function [ GetMyExperience ]


Iroki

2008-12-22 12:05:26

This function download experience from runescape highscores.


{*******************************************************************************
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:


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

bullzeye95

2008-12-22 13:58:51

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

Iroki

2008-12-22 14:05:58

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

bullzeye95

2008-12-22 14:52:59

StringReplace() is Replace().

Iroki

2008-12-22 15:00:31

but i still need to allow conection :)

NiCbaZ

2008-12-22 15:35:40

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

Bobarkinator

2008-12-22 15:56:51

From: manfromczech
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…

Iroki

2008-12-22 16:14:20

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

scar only:


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.

A G E N T

2008-12-23 13:36:12

From: manfromczech
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.

Iroki

2008-12-23 13:53:27

From: A G E N T
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.

Nava2

2008-12-24 00:44:56

Also, using two explode functions would be more efficient :)

Mine:

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 :)

the scar noob

2008-12-24 09:04:58

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

-Tsn.

Iroki

2008-12-24 09:41:04

From: the scar noob
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??

Sir R. M8gic1an

2008-12-25 07:43:55

From: manfromczech
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

Dervish

2008-12-26 07:28:30

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

Iroki

2008-12-26 07:49:44

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

n3ss3s

2008-12-26 09:04:54

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?

Dervish

2008-12-26 10:26:28

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