Kyle Undefined
2012-01-19 19:33:54
Here's the grandexchange.simba file that works with SRL5, one silly little line wouldn't allow this to compile.
MouseItem(InvSpot, True); on Line 633, which is in GESell(), error'd out this file.
Here's the fixed version:
MouseItem(InvSpot, True); on Line 633, which is in GESell(), error'd out this file.
Here's the fixed version:
//------------------------------------------------------------------------//
//-- SRL Resource Library --//
//-- ? Grand Exchange Routines --//
//------------------------------------------------------------------------//
// * function InGE: boolean; // * by Rasta Magician
// * function GEIsMember: boolean; // * by Rasta Magician
// * function GESellMenu: boolean; // * by Rasta Magician
// * function GEBuyMenu: boolean; // * by Rasta Magician
// * procedure GEMenuExit; // * by Rasta Magician
// * function GESpotToTBox(spot: integer): TBox; // * by Rasta Magician
// * function GEIsSpotFree(spot: integer):boolean; // * by Rasta Magician
// * function GEFinishedAt(spot: integer): boolean; // * by Rasta Magician
// * procedure GERecoverAtEx(spot: integer; abort:boolean); // * by Rasta Magician
// * procedure GERecoverAt(spot: integer); // * by Rasta Magician
// * procedure GERecoverFinishedAt(spot: integer); // * by Rasta Magician
// * procedure GEAbortAll; // * by Rasta Magician
// * procedure GERecoverAll; // * by Rasta Magician
// * procedure GERecoverFinished; // * by Rasta Magician
// * function GEFindFreeSpot(var spot:integer): boolean; // * by Rasta Magician
// * function GESellAt(spot: integer): boolean; // * by Rasta Magician
// * function GEBuyAt(spot: integer): boolean; // * by Rasta Magician
// * function GESetPrice(value: string): boolean; // * by Rasta Magician
// * procedure GESetQuantity(Q: string); // * by Rasta Magician
// * function GEConfirmOffer: boolean; // * by Rasta Magician
// * function GEBuy(What, Price, Quantity: string): boolean; // * by Rasta Magician
// * function GESell(Price, Quantity: string; InvSpot: integer): boolean; // * by Rasta Magician
{*******************************************************************************
function InGE: boolean;
By: Rasta Magician
Description: Checks if we are in GE
*******************************************************************************}
function InGE: boolean;
var
x, y, GEIN: integer;
begin
GEIN := DTMFromString('78DA636C6360607067C00A1861F47422D4EC2' +
'242CD3722D4F0311256A345580D00826F04BE');
Result := FindDTM(GEIN,x,y,127, 61,393, 75);
FreeDTM(GEIN);
end;
{*******************************************************************************
function GEIsMember: boolean;
By: Rasta Magician
Description: Checks if it is a member account using GE
*******************************************************************************}
function GEIsMember: boolean;
begin
if not InGE then exit;
if GetColor(411, 167) <> srl_outline_black then
if GetColor(410, 155) <> 5199452 then
begin
Result := true;
exit;
end;
if GetColor(411, 167) <> 5199452 then //to avoid jagex moving 1px
if GetColor(410, 155) <> srl_outline_black then
begin
Result := true;
exit;
end;
Result := false;
end;
{*******************************************************************************
function GESellMenu: boolean;
By: Rasta Magician
Description: Checks if we are in the sell menu
*******************************************************************************}
function GESellMenu: boolean;
begin
if not InGE then exit;
Result := (GetColor(187, 73) = 45055);
end;
{*******************************************************************************
function GEBuyMenu: boolean;
By: Rasta Magician
Description: Checks if we are in the buy menu
*******************************************************************************}
function GEBuyMenu: boolean;
begin
if not InGE then exit;
Result := (GetColor(186, 74) = 61385);
end;
{*******************************************************************************
procedure GEMenuExit;
By: Rasta Magician
Description: Exits the Buy or Sell menu
*******************************************************************************}
procedure GEMenuExit;
var i, x:integer;
begin
if not InGE then exit;
if not GESellMenu then
if not GEBuyMenu then
exit;
MMouse(40, 291, 18, 9);
for i:= 0 to 5 do
begin
wait(100);
if IsUpText('ack') then break;
end;
if IsUpText('ack') then
begin
GetMousePos(x, i);
Mouse(x, i, 0, 0, true);
for i:= 0 to 5 do
begin
wait(150);
if not GESellMenu then
if not GEBuyMenu then
break;
end;
end;
end;
{*******************************************************************************
function GESpotToTBox(spot: integer): TBox;
By: Rasta Magician
Description: Returns the coords of a box in GE
*******************************************************************************}
function GESpotToTBox(spot: integer): TBox;
var
i, x1, x2, y1, y2: integer;
begin
{
box width: 140
box height: 112
gap hor: 16
gap ver: 8
}
if spot > 3 then
i := spot - 3 - 1
else
i := spot - 1 ;
x1 := 32 + (16 + 140)*i;
x2 := 172 + (16 + 140)*i;
if spot > 3 then
i := 1
else
i := 0;
y1 := 82 + (112 + 8)*i;
y2 := 194 + (112 + 8)*i;
Result := IntToBox(x1, y1, x2, y2);
end;
{*******************************************************************************
function GEIsSpotFree(spot: integer):boolean;
By: Rasta Magician
Description: Checks if a spot is available for buying/selling
*******************************************************************************}
function GEIsSpotFree(spot: integer):boolean;
var TB: TBox;
begin
if not InGE then exit;
if spot > 2 then
if not GEIsMember then
exit;
TB := GESpotToTBox(spot);
Result := (GetColor(TB.x1 + 9, TB.y2 - 30) <> 0);
writeln('coords: '+IntToStr(TB.x1+9)+', '+ IntToStr(TB.y2 -30));
end;
{*******************************************************************************
function GEFinishedAt(spot: integer): boolean;
By: Rasta Magician
Description: Checks if a trade has been concluded at spot: spot
*******************************************************************************}
function GEFinishedAt(spot: integer): boolean;
var TB: TBox;
begin
if not InGE then exit;
if spot > 2 then
if not GEIsMember then exit;
if not GEIsSpotFree(spot) then
begin
TB := GESpotToTBox(spot);
Result := ( GetColor(TB.x1 + 103, TB.y2 - 20) = 1999423 );
end;
end;
{*******************************************************************************
procedure GERecoverAtEx(spot: integer; abort:boolean);
By: Rasta Magician
Description: Collects the items traded received at a certain spot
Aborts the trade is boolean abort is set to true
*******************************************************************************}
procedure GERecoverAtEx(spot: integer; abort:boolean);
var
TB: TBox;
i, x, y: integer;
begin
if not InGE then exit;
if GEIsSpotFree(spot) then exit;
if spot > 2 then
if not GEIsMember then
exit;
TB := GESpotToTBox(spot);
MouseBox(TB.x1, TB.y1, TB.x2, TB.y2, 1);
wait(200);
for i:= 0 to 10 do
begin
if (GESellMenu)or(GEBuyMenu) then
break;
wait(150);
end;
if abort then
if (GetColor(359, 312) <> 1999423) then
begin
MMouse(364, 285, 5, 5); //moving to button
wait(100);
for i:= 0 to 5 do // waiting text
begin
if IsUpText('bort') then break;
wait(100);
end;
if IsUpText('bort') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
for i:= 0 to 10 do //waiting until aborted
begin
wait(100);
if (GetColor(202, 309) = 1048714) then break;
end;
wait(200+Random(300));
end;
//collecting spot 1 //
MMouse(416, 299, 5, 5);
for i:= 0 to 5 do // waiting text
begin
if IsUpText('ollect') then break;
wait(100);
end;
if IsUpText('ollect') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
wait(100+Random(200));
//collecting spot 1 //
if (GetColor(467, 298) <> 2176579) then // spot 2
begin
MMouse(467, 298, 5, 5);
for i:= 0 to 5 do // waiting text
begin
if IsUpText('ollect') then break;
wait(100);
end;
if IsUpText('ollect') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
wait(100+Random(200));
end;
for i:=0 to 10 do
begin
wait(150);
if not GESellMenu then
if not GEBuyMenu then
break;
end;
GEMenuExit; //just if something went wrong
end;
{*******************************************************************************
function procedure GERecoverAt(spot: integer);
By: Rasta Magician
Description: Recovers items at spot: spot, does not abort the trade
*******************************************************************************}
procedure GERecoverAt(spot: integer);
begin
GERecoverAtEx(spot, false);
end;
{*******************************************************************************
procedure GERecoverFinishedAt(spot: integer);
By: Rasta Magician
Description: Recovers items at spot: spot if the trade is concluded
*******************************************************************************}
procedure GERecoverFinishedAt(spot: integer);
begin
if not InGE then exit;
if GEFinishedAt(spot) then
GERecoverAtEx(spot, false);
end;
{*******************************************************************************
procedure GEAbortAll;
By: Rasta Magician
Description: Aborts and recovers all current trades
*******************************************************************************}
procedure GEAbortAll;
var
i:integer;
begin
for i:= 1 to 6 do
GERecoverAtEx(i, true);
end;
{*******************************************************************************
procedure GERecoverAll;
By: Rasta Magician
Description: Recovers all current trades, does not abort
*******************************************************************************}
procedure GERecoverAll;
var
i:integer;
begin
for i:= 1 to 6 do
GERecoverAt(i);
end;
{*******************************************************************************
procedure GERecoverFinished;
By: Rasta Magician
Description: Recovers all finished trades
*******************************************************************************}
procedure GERecoverFinished;
var
i:integer;
begin
for i:= 1 to 6 do
GERecoverFinishedAt(i);
end;
{*******************************************************************************
function GEFindFreeSpot(var spot:integer): boolean;
By: Rasta Magician
Description: Finds a free spot to trade in
*******************************************************************************}
function GEFindFreeSpot(var spot:integer): boolean;
var
i:integer;
begin
if not InGE then exit;
Result := false;
spot := 0;
for i:= 1 to 6 do
if GEIsSpotFree(i) then
begin
spot := i;
Result := true;
break;
end;
end;
{*******************************************************************************
function GESellAt(spot: integer): boolean;
By: Rasta Magician
Description: Presses the sell button at spot: spot
*******************************************************************************}
function GESellAt(spot: integer): boolean;
var
TB: TBox;
x, y: integer;
begin
if not InGE then exit;
if not GEIsSpotFree(spot) then
begin
writeln('space is not free!');
exit;
end;
TB := GESpotToTBox(spot);
MMouse(TB.x1 + 100, TB.y1 + 65, 5, 5);
wait(150+Random(75));
if IsUpText('ell') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
for x:= 0 to 9 do
begin
wait(100);
if GESellMenu then break;
end;
Result := GESellMenu;
end;
{*******************************************************************************
function GEBuyAt(spot: integer): boolean;
By: Rasta Magician
Description: Presses the buy button at spot: spot
*******************************************************************************}
function GEBuyAt(spot: integer): boolean;
var
TB: TBox;
x, y: integer;
begin
if not InGE then exit;
if not GEIsSpotFree(spot) then
begin
writeln('space is not free!');
exit;
end;
TB := GESpotToTBox(spot);
MouseBox(TB.x1 + 35, TB.y1 + 50, TB.x1 + 65, TB.y1 + 80, 3);
wait(150+Random(75));
if IsUpText('Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
for x:= 0 to 9 do
begin
wait(100);
if GEBuyMenu then break;
end;
Result := GEBuyMenu;
end;
{*******************************************************************************
function GESetPrice(value: string): boolean;
By: Rasta Magician
Description: Sets the price of an item.
'0', 'min' - Minimum Value
'1', 'med' - Market Value
'2', 'max' - Max value
Other - Exact value
*******************************************************************************}
function GESetPrice(Value: Variant): boolean;
begin
if not InGE then exit;
if not GESellMenu then
if not GEBuyMenu then
exit;
if value = 'min' then value := 0;
if value = 'med' then value := 1;
if value = 'max' then value := 2;
wait(100+Random(50));
case value of
1: MouseBox(269, 208, 304, 232, 1); // min price
2: begin end; // market price
3: MouseBox(376, 210, 408, 233, 1); // max price
else begin
MouseBox(429, 209, 462, 234, 1);
wait(100+Random(100));
TypeSend(IntToStr(value));
wait(200+Random(100));
if IsChatBoxTextAnyLine('price range', clblack) then
begin
writeln('wrong price! Out of Price Range!');
GEMenuExit;
end;
end;
end;
Result := true;
end;
{*******************************************************************************
procedure GESetQuantity(Q: string);
By: Rasta Magician
Description: Sets the price of an item.
Options: '1', '10', '100', '1000'(buy), 'all'(sell),
Other - Exact Value
*******************************************************************************}
procedure GESetQuantity(Q: string);
var i:integer;
begin
if not InGe then exit;
if not GESellMenu then
if not GEBuyMenu then
exit;
case lowercase(Q) of
'1': Mouse(72, 220, 5, 5, true);
'10': Mouse(115, 219, 5, 5, true);
'100': Mouse(155, 220, 5, 5, true);
'all', '1000': Mouse(196, 222, 5, 5, true);
else begin
Mouse(238, 223, 5, 5, true);
for i:= 0 to 3 do
begin
wait(450);
if (GetColor(259, 428) = 8388608) then
if (GetColor(256, 400) = 0) then
break;
end;
TypeSend(Q);
end;
end;
end;
{*******************************************************************************
function GEConfirmOffer: boolean;
By: Rasta Magician
Description: Confirms an offer
Returns false if it wasn't able to do so
*******************************************************************************}
function GEConfirmOffer: boolean;
var x, y : integer;
begin
if not InGE then exit;
if not GESellMenu then
if not GEBuyMenu then
exit;
Result := true;
MMouse(215, 284, 96, 21);
wait(250+Random(100));
if IsUpText('ffer') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
wait(1000+Random(200));
end;
if GESellMenu or GEBuyMenu then
begin
writeln('could not confirm offer');
GEMenuExit;
Result := false;
end;
end;
{*******************************************************************************
function GEBuy(What, Price, Quantity: string): boolean;
By: Rasta Magician
Description: Buys an item from the GE
What (item name) has to be exact
Price: 'min', 'med', 'max', exact value
Quantity: '1', '10', '100', '1000', exact value
*******************************************************************************}
function GEBuy(What, Price, Quantity: string): boolean;
var
free, x, y:integer;
begin
if not InGE then exit;
if not GEFindFreeSpot(free) then exit;
if GEBuyAt(free) then
begin
wait(50+ Random(50));
if (GetColor(231, 362) <> 23200) then //checking for Item Search
begin
Mouse(125, 117, 7, 7, true);
wait(200+random(50));
end;
TypeSend(lowercase(What));
wait(150+Random(100));
if FindColor(x, y, 23200, 66, 348, 120, 354) then //if it finds our thing
begin
Mouse(x, y, 5, 3, true);
wait(100+Random(100));
end else begin
writeln('Wrong object name');
exit;
end;
wait(100+Random(100));
if not GESetPrice(Price) then exit;
wait(200+Random(100));
GESetQuantity(Quantity);
wait(200+Random(100));
Result := GEConfirmOffer;
end;
end;
{*******************************************************************************
function GESell(Price, Quantity: string; InvSpot: integer): boolean;
By: Rasta Magician
Description: Sells an item at GE
Price: 'min', 'med', 'max', exact value
Quantity: '1', '10', '100', 'all', exact value
InvSpot: the Invspot where you have your item
*******************************************************************************}
function GESell(Price, Quantity: string; InvSpot: integer): boolean;
var
free :integer;
begin
if not InGE then exit;
if not GEFindFreeSpot(free) then exit;
if GESellAt(free) then
begin
wait(100+Random(100));
MouseItem(InvSpot, mouse_Left);
wait(200+Random(100));
GESetPrice(Price);
wait(200+Random(100));
GESetQuantity(Quantity);
wait(200+Random(100));
Result := GEConfirmOffer;
end;
end;