putonajonny
2011-12-19 13:42:29
It gets the current GE price, only problem is that prices often return as 22.5k though items of this price are not normally used in scripts so it shouldn't be a problem,Problem now fixed, should be useful for profit calculation.
ID's can be got from the GE website or many other websites such as this one
If you want to try it out then you can use some of the following:
Say somebody made a Superheating Script they could do the following:
At the same time I may as well post this function, not sure what the use would be but it gets the name of that Object ID:
Running the following:
Gives me:
function GetPrice(ObjID : Integer) : Integer;
Var
str, str2, str3, str4 : string;
startat, endat, com, k, b, m :integer;
begin
str := GetPage('http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj='+IntToStr(ObjID))
startat := Pos('<th scope="row">Current guide price:</th>',str)
If(startat>0) then
begin
endat := Pos('<th scope="row">Today',str)
str2 := Copy(str,(startat+46),endat-startat-63);
k := Pos('k',str2)
com := Pos(',',str2)
b := Pos('b',str2)
m := Pos('m',str2)
str4 := str2
If(k > 0) then
begin
str3 := Copy(Str2,1,k-1)
str4 := IntToStr(StrToInt(Copy(Str3,1,Length(Str3)-2)+Copy(Str3,Length(Str3),1))*100)
end;
If(b > 0) then
begin
str3 := Copy(Str2,1,b-1)
str4 := IntToStr(StrToInt(Copy(Str3,1,Length(Str3)-2)+Copy(Str3,Length(Str3),1))*100000000)
end;
If(m > 0) then
begin
str3 := Copy(Str2,1,m-1)
str4 := IntToStr(StrToInt(Copy(Str3,1,Length(Str3)-2)+Copy(Str3,Length(Str3),1))*100000)
end;
If(com > 0) then
begin
str4 := Copy(Str2,1,com-1)+Copy(Str2,com+1,Length(str2)-com)
end;
Result := StrToInt(str4)
end else
begin
Result := -1
end
end;ID's can be got from the GE website or many other websites such as this one
If you want to try it out then you can use some of the following:
- 554 - fire rune
- 1517 - maple logs
- 1048 - white partyhat
- 1734 - thread
- 2615 - Rune platebody (g)
Say somebody made a Superheating Script they could do the following:
begin
//Setup SRL and smart here
ProfitPerBar := StrToInt(GetPrice(2353))-StrToInt(GetPrice(440))-2*StrToInt(GetPrice(453))-StrToInt(GetPrice(561));
WriteLn('My awesome script......');
WriteLn('Profit Per Bar: '+IntToStr(ProfitPerBar));
MarkTime(i)
Repeat
Cast;
Bank;
TIMESCAST := TIMESCAST+Random(2); //Just so that the profit increases with each progress report
If(TimeFromMark(i)>5000) then
begin
WriteLn('')
WriteLn('[---------------------------------]')
WriteLn('[' + padr(padl('Progress Report', 17 + Length('Progress Report') / 2), 33) + ']');
WriteLn('[---------------------------------]')
WriteLn(PadR('[ Times Cast: ' + IntToStr(TIMESCAST), 34) + ']');
WriteLn(PadR('[ Profit Made: ' + IntToStr(ProfitPerBar*TIMESCAST), 34) + ']');
WriteLn('[---------------------------------]')
WriteLn('')
MarkTime(i)
end;
Wait(500)
Until(False)
end.At the same time I may as well post this function, not sure what the use would be but it gets the name of that Object ID:
function GetName(ObjID : Integer) : String;
Var
str : string;
startat, endat :integer;
begin
str := GetPage('http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj='+IntToStr(ObjID))
startat := Pos('<h5>',str)
If(startat>0) then
begin
endat := Pos('</h5>',str)
Result := Copy(str,startat+4,endat-startat-4);
end else
begin
Result := 'ERROR'
end
end; Running the following:
WriteLn(GetName(554))
WriteLn(GetPrice(554))
WriteLn(GetName(1517))
WriteLn(GetPrice(1517))
WriteLn(GetName(1048))
WriteLn(GetPrice(1048))
WriteLn(GetName(1734))
WriteLn(GetPrice(1734))
WriteLn(GetName(2615))
WriteLn(GetPrice(2615))
WriteLn(GetName(2353))
WriteLn(GetPrice(2353))Gives me:
Compiled successfully in 967 ms.
Fire rune
30
Maple logs
22
White partyhat
2100000000
Thread
3
Rune platebody (g)
444400
Steel bar
1229
Successfully executed.