Simba Code:
//------------------------------------------------------------------------//
//-- 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;
Simba Code:
program GEFlipper;
{$i srl/srl/misc/smart.simba}
{$i SRL/SRL.simba}
{$i srl/srl/misc/grandexchange.simba}
var
BuyIMG, SellIMG, BuyPrice, ItemSearchBox, Profit, Profit2, SetPriceBox, ConfirmBox, CollectionBox1, CollectionBox2, SellPrice, BoughtFor1, SoldFor1: integer;
incprofit: boolean;
const
ITEM1_NAME = 'Lobster'; //The name of item 1 - Make sure it's inbetween two apostrophes -> ''
ITEM1_COLOUR = 1992652; //The colour of item 1 - Use the colour picker and find a somewhat unique colour about the item. e.g. for rune armour, go for the blueish part not the darker outlines
ITEM1_SPOT = 1; //What spot should be allocated to item 1 (From 1 to 6)
ITEM1_REFRESH = 2; // Time (mins) after which the script should abort an offer for not Selling or Buying
ITEM1_LIMIT = 1000; //Make sure you put in the correct limit else the script will not function properly
ITEM1_PERCENTAGEABOVE = 5; //Percentage above the mid price to BuyPrice at
ITEM1_PERCENTAGEBELOW = 5; //Percentage below the mid price to SellPrice at
Version = 0.2;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'iamond', 'uby'];
end;
function isBuyOpen: boolean;
var
x, y: integer;
begin
BuyIMG := DTMFromString('m6wAAAHic42ZgYGhhguB6IO4E4gYgbofyO4C4CYibgbgViFcxMjCsY4TQILwWyl8GxMuBeCkQL4TSjb5yDPJSwjjxiXcMcEwKYCQBIwEAN3IVQQ==');
Result := (FindDTM(BuyIMG, x, y, MSX1, MSY1, MSX2, MSY2));
FreeDTM(BuyIMG);
end;
function isSellOpen: boolean;
var
x, y: integer;
begin
SellIMG := DTMFromString('m1gAAAHic42JgYNBkYWBQYYHQelCsBsQ6QKwNxBpArArEsxgZGGYC8Twgng3EM6BsEJ4MxBOBeCoQN/rKMchLCWPF/9YxgDGITSxgJBIjAACdvg40');
Result := (FindDTM(SellIMG, x, y, MSX1, MSY1, MSX2, MSY2));
FreeDTM(SellIMG);
end;
function isItemSearchOpen: boolean;
var
x, y: integer;
begin
ItemSearchBox := DTMFromString('m6wAAAHic42ZgYBAEYlUg5gFiISAWBWIVIGaEYmWoPAgIADE7ECtC+SBaAYoZkdSAzFw9p4ohO96FKEwKYCQBIwEAJoEN9g==');
Result := (FindDTM(ItemSearchBox, x, y, 10, 348, 58, 388));
FreeDTM(ItemSearchBox);
end;
function isSetOpen(State: integer): boolean;
var
x, y:integer;
begin
SetPriceBox := DTMFromString('mwQAAAHic42RgYLjLwsBwBorfQPEdKD4NxG+BOIaJgSEQiNOhGMQOAOIMJogcCKdHewNNYwRjMTExOBsVEwbYdOE0BQC2mgyY');
If State = 0 then
begin
Result := FindDTM(SetPriceBox, x, y, 370, 209, 404, 233);
end else
If State = 1 then
begin
Result := FindDTM(SetPriceBox, x, y, 220, 209, 254, 233);
end else
If State = 2 then
begin
Result := FindDTM(SetPriceBox, x, y, 179, 209, 213, 233);
end;
FreeDTM(SetPriceBox);
end;
function isConfirmBoxVisible: boolean;
var
x, y:integer;
begin
ConfirmBox := DTMFromString('mwQAAAHic42RgYEhhYWBQg+LZUJwExMlArArEc4B4ORMDwyQg3gXFIPZEIN4NxEuAeBkQn5nBAAd8fHwM5AJGIjAcAABIKgsY');
Result := FindDTM(ConfirmBox, x, y, 204, 274, 323, 316);
FreeDTM(ConfirmBox);
end;
function isCollectionBoxEmpty1: boolean;
var
x, y: integer;
begin
CollectionBox1 := DTMFromString('mAAEAAHic42FgYJjHzMDQA8SzgXg9EM8F4k4o3gDE64C4G0p3AXEzEwNDMRAXAXEjEE9hgoj1QnEJEE+G4mogdjZTZLA1kmWI8LFg8LLTAuNwLxOGEA9jMAbxfRy0GVwtVMBqRYBuIgUzkoiRAQDlYxc1');
Result := (FindDTM(CollectionBox1, x, y, 448, 280, 487, 315));
FreeDTM(CollectionBox1);
end;
function isCollectionBoxEmpty2: boolean;
var
x, y: integer;
begin
CollectionBox2 := DTMFromString('mVAEAAHicE2BgYJjHzMDQBcSdUBrE3wDE64B4DpSeCsTrgXgSkjqQmqVA3MzEwFAMxE1APAWIp0LZILEiIJ4MFauGilUBcTcQd0LFJ3aZMRQXqsBxVooEQ2qCFENOphSYH5PMDBZLTGFmiIpgAIuBaJA8SJwSIALEjBRidAAASXYhWw==');
Result := (FindDTM(CollectionBox2, x, y, 448, 280, 487, 315));
FreeDTM(CollectionBox2);
end;
function InPinGE(Pin: string): Boolean; //Ripped out of the SRL - Made minor changes to work with the GE interface instead of the bank.
var
Tx, Ty, X, Y, H, I, J, Tries, ColorCount : Integer;
Boxes: array of TBox;
begin
Result := False;
if not PinScreen then Exit;
if (GetNumbers(Pin) <> Pin) then
begin
srl_Warn('InPin', '''' + Pin + ''' is not a valid Pin', warn_AllVersions);
Exit;
end;
if (Length(Pin) <> 4) then
begin
srl_Warn('InPin', 'Pin must be 4 digits long', warn_AllVersions);
Exit;
end;
Boxes := [IntToBox(37, 107, 100, 170), IntToBox(127, 107, 190, 170), IntToBox(217, 107, 280, 170), IntToBox(307, 107, 370, 170),
IntToBox(37, 179, 100, 242), IntToBox(127, 179, 190, 242), IntToBox(217, 179, 280, 242),
IntToBox(37, 251, 100, 314), IntToBox(127, 251, 190, 314), IntToBox(217, 251, 280, 314)];
while PinScreen do
begin
for I := 1 to 4 do
begin
if not PinScreen then Break;
ColorCount := CountColorTolerance(clWhite, 150, 80, 380, 100, 10);
// Counts the "Now click the NUM_X digit.". This is used later on.
GetMousePos(X, Y);
if (FindText(Tx, Ty, Pin[I], UpCharsEx, 30, 100, 383, 319)) then
begin
H := High(Boxes);
for J := 0 to H do
if IntInBox(Tx, Ty, Boxes[J]) then
begin
with Boxes[J] do
if PinScreen then
MouseBox(x1, y1, x2, y2, 1);
Break;
end;
end else
begin
H := High(Boxes);
for J := 0 to H do
if IntInBox(X, Y, Boxes[J]) then
begin
with Boxes[J] do
if PinScreen then
MouseBox(x1, y1, x2, y2, 1);
Break;
end;
end;
Wait(100);
while (CountColorTolerance(clWhite, 150, 80, 380, 100, 10) = ColorCount) do
Wait(500);
Wait(RandomRange(300, 600));
if InGE then
begin
Result := True;
Exit;
end;
end;
WaitFunc(@InGE, 50, 300);
ClickContinue(True, True);
while not FindColor(Tx, Ty, 0, 7, 460, 69, 474) do
begin
Wait(500);
if not LoggedIn then
Exit;
end;
Inc(Tries);
if Tries > 2 then
begin
srl_Warn('InPin', '''' + Pin + ''' is not the correct Pin', warn_AllVersions);
ClosePinScreen;
Exit;
end;
end;
Result := InGE;
end;
function OpenGENPCEx: Boolean; //Ripped out of the SRL - Slightly edited version of Home's OpenBankNPC
var
NPCBox :TBox;
Colors, NPCArray :TPointArray;
ATPA: T2DPointArray;
MSNPC, NPCPoint :TPoint;
TempCTS, C, HiNPC, II, I :Integer;
begin
Result := False;
Result := (InGE) or (PinScreen);
If Result then Exit;
NPCArray := GetMinimapDots('NPC');
HiNPC := High(NPCArray);
If Length(NPCArray) = 0 then Exit;
SortTPAFrom(NPCArray, Point(MMCX, MMCY));
for I := 0 to HiNPC do
begin
NPCPoint := MMToMS(NPCArray[I])
If NPCPoint = Point(-1, -1) then Continue;
NPCBox := IntToBox(NPCPoint.X - 40, NPCPoint.Y - 40, NPCPoint.X + 40, NPCPoint.Y + 40)
If PixelShift(NPCBox, 200) > 500 then Continue;
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.52);
FindColorsTolerance(Colors, 6852026, NPCBox.X1, NPCBox.Y1, NPCBox.X2, NPCBox.Y2, 13);
ATPA := TPAToATPAEx(Colors, 15, 20);
SortATPASize(ATPA, True);
for II := 0 to High(ATPA) do
begin
MSNPC := MiddleTPA(ATPA[II]);
MMouse(MSNPC.X, MSNPC.Y, 3, 3);
If WaitUpTextMulti(['rand Exchange clerk'], 200) then
begin
Mouse(MSNPC.X, MSNPC.Y, 1, 1, mouse_Right);
If WaitOptionMulti(['xchange G'], 300) then
MarkTime(c);
Repeat
Wait(RandomRange(50, 100));
Until (InGE) or (PinScreen) or (TimeFromMark(C) > 4500);
if (Players[CurrentPlayer].Pin <> '') then
InPinGE(Players[CurrentPlayer].Pin);
Result := (InGE) or (PinScreen);
If Result then
begin
ColorToleranceSpeed(TempCTS);
Exit;
end
else
ColorToleranceSpeed(TempCTS);
end;
end;
end;
end;
procedure ClickBack;
var
i: integer;
begin
For i := 0 to 2 do
If (isBuyOpen or isSellOpen) then
begin
Mouse(45, 298, 10, 10, mouse_Left); //Clicks the arrow to get back
Wait(Random(1000));
end else
break;
end;
function isInGE: boolean;
var
i: integer;
begin
If InGE then
begin
result := True
end else
begin
result := False
end;
For i := 0 to 4 do
begin
If InGE then
begin
Break;
end else
SetAngle(SRL_ANGLE_HIGH);
MakeCompass(Random(360));
OpenGENPCEx;
Wait(1000 + Random(500));
end;
If not InGE then
begin
Writeln('Could not find a Grand Exchange Clerk. Make sure you start near one');
TerminateScript;
end;
end;
function GetNumerals(const s: string): string; //Credit to Echo_
var
i, j: Integer;
numArray: array of string;
begin
numArray := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
for i := 1 to High(s) do
for j := 0 to High(numArray) do
begin
if not (s[i] = numArray[j]) then Continue;
Result := Result + s[i];
end;
end;
function GetMidPrice: integer;
begin
result := StrToInt(GetNumerals(GetTextAtExWrap(296, 186, 440, 199, 0, 10, 1, 6400255, 5, 'UpCharsEx')));
end;
function GetMidPrice1: integer;
begin
result := StrToInt(GetNumerals(GetTextAtExWrap(296, 186, 440, 199, 0, 10, 1, 6400255, 5, 'UpCharsEx')));
end;
function GetQuantity: integer;
begin
result := StrToInt(GetNumerals(GetTextAtExWrap(98, 183, 211, 200, 0, 10, 1, 6400255, 5, 'UpCharsEx')));
end;
function BoughtFor: integer;
begin
result := StrToInt(GetNumerals(GetTextAtExWrap(117, 287, 327, 300, 0, 10, 1, 39372, 5, 'StatChars')));
end;
function SoldFor: integer;
begin
result := StrToInt(GetNumerals(GetTextAtExWrap(117, 287, 327, 300, 0, 10, 1, 39372, 5, 'StatChars')));
end;
Procedure SetPrice(State, Percentage, Price: extended);
var
i, i1: integer;
decimal: Extended;
begin
If State = 0 then
begin
decimal := round(GetMidPrice * ((100 - Percentage) / 100))
end else
begin
If State = 1 then
begin
decimal := round(GetMidPrice1 * ((100 + Percentage) / 100))
end else
If State = 2 then
begin
decimal := Price
end;
end;
For i := 0 to 4 do
begin
If (GetMidPrice = decimal) then
begin
Break;
end else
If not isSetOpen(0) then
begin
writeln('Could not find the set price box. Terminating');
TerminateScript;
end else
for i1 := 0 to 4 do
begin
Mouse(385, 222, 10, 10, mouse_Left); //Clicks on the '...' to enter a custom price
wait(1500 + Random(500));
If (GetTextAtEx(124, 393, 10, UpCharsEx, False, False, 0, 10, 0, 810, False, tr_AllChars) = ('Enter the price you wish to sell for: |')) or (GetTextAtEx(124, 393, 10, UpCharsEx, False, False, 0, 10, 0, 810, False, tr_AllChars) = ('Enter the price you wish to buy for: |')) then
begin
TypeSendEx(FloatToStr(decimal), True);
Wait(500 + Random(500));
If (GetMidPrice = decimal) then
begin
break;
end;
end else
writeln('Failed to set price');
end;
end;
If isConfirmBoxVisible then
begin
Mouse(263, 290, 10, 10, mouse_Left); //Clicks confirm
end else
begin
writeln('Could not detect the confirm box, terminating.');
TerminateScript;
end;
end;
Procedure SetQuantity(Quantity: integer);
var
i, i1: integer;
begin
For i := 0 to 4 do
begin
If (GetQuantity = Quantity) then
begin
Break;
end else
begin
If not isSetOpen(1) then
begin
writeln('Could not find the set quantity box. Terminating');
TerminateScript;
end else
begin
for i1 := 0 to 4 do
begin
Mouse(238, 221, 10, 10, mouse_Left); //Clicks on the '...' to enter a custom price
wait(1000 + Random(500));
If (GetTextAtEx(124, 393, 10, UpCharsEx, False, False, 0, 10, 0, 810, False, tr_AllChars) = 'Enter the amount you wish to purchase: |') or (GetTextAtEx(124, 393, 10, UpCharsEx, False, False, 0, 10, 0, 810, False, tr_AllChars) = 'Enter the amount you wish to sell: |') then
begin
TypeSendEx(IntToStr(Quantity), True);
Wait(500 + Random(500));
If (GetQuantity = Quantity) then
begin
break;
end;
end else
writeln('Could not detect the text');
end;
end;
end;
end;
end;
Procedure SetToAll;
begin
If isSetOpen(2) then
begin
Mouse(194, 220, 5, 5, mouse_Left);
wait(1000 + Random(500));
end else
Writeln('Could not find the set to All box');
end;
procedure ItemCollection;
var
i: integer;
begin
For i := 0 to 2 do
begin
If isCollectionBoxEmpty1 then
begin
break;
end else
begin
Mouse(463, 293, 10, 10, mouse_Left); //clicks on the second item to collect it
Wait(500 + Random(500));
If isCollectionBoxEmpty2 then
begin
break;
end;
end;
end;
For i := 0 to 4 do
begin
If not InGE then
begin
Mouse(416, 296, 10, 10, mouse_Left); //Clicks on the first item to collect it
Wait(500 + Random(500));
end else
begin
break;
end;
end;
end;
procedure GEBuyOrSellAtEx(State, Spot: integer); //0 is Buy, 1 is Sell
var
x, y, i, XB, YB, XS, YS: integer;
begin
Case Spot of
1: begin
XB := 72;
YB := 152;
XS := 140;
YS := 146;
end;
2: begin
XB := 227;
YB := 151;
XS := 290;
YS := 152;
end;
end;
If State = 0 then
begin
x := XB
y := YB
end else
begin
x := XS
y := YS
end;
If InGE and (not isBuyOpen) or (not isSellOpen) then
For i := 0 to 4 do
begin
Mouse(x, y, 5, 5, mouse_Left);
Wait(1000 + random (500));
If isBuyOpen or isSellOpen then
break;
end;
end;
function FindHigh(Spot, Colour: integer; Percentage: extended; Item: string): integer;
var
x, y, i, i1, n, c, x1, y1: integer;
isFound: boolean;
begin
If isBuyOpen or isSellOpen then
begin
ClickBack;
end;
While not isInGE do
begin
isInGE;
end;
For i := 0 to 4 do
begin
If GEIsSpotFree(Spot) then
begin
break;
end else
begin
GERecoverAtEx(Spot, True);
end;
end;
For i := 0 to 2 do
begin
If isBuyOpen then
begin
break;
end;
If InGE then
begin
GEBuyOrSellAtEx(0, Spot);
Wait(500 + Random(500));
end else
begin
writeln('Not in GE');
TerminateScript;
end;
end;
If not isBuyOpen then
begin
Writeln('Could not get the buying screen open');
TerminateScript;
end;
For i := 0 to 2 do
begin
If isItemSearchOpen then
begin
break;
end else
begin
Mouse(125, 116, 10, 10, mouse_Left);
Wait(1000 + Random(500));
end;
end;
i1 := 0
While (isFound = False) or (i1 < 6) do
begin
inc(i1)
isFound := False
If not (GetTextAtEx(25, 453, 10, SmallChars, False, False, 0, 10, 16777215, 810, False, tr_AllChars) = '*') then
begin
For i := 0 to 15 do
begin
TypeSendEx(chr(8), false);
If (GetTextAtEx(25, 453, 10, SmallChars, False, False, 0, 10, 16777215, 810, False, tr_AllChars) = '*') then
break;
end;
end;
TypeSendEx(Item, false);
Wait(2000 + Random(500));
n := 342
While n < 440 do
begin
If GetTextAtEx(65, n, 10, SmallChars, False, False, 0, 10, 23200, 810, False, tr_AllChars) = Item then
begin
isFound := True
x1 := 65 + 30
y1 := n + 6
Break;
end;
n := n + 16
end;
If isFound = True then
begin
break;
end;
If (n > 440) then
Writeln('Item not found in searchbox.');
end;
If not FindColorTolerance(x, y, Colour, 102, 95, 144, 130, 20) then //looks for the colour in the item icon thing
For i := 0 to 2 do
begin
Mouse(x1, y1, 10, 3, mouse_Left); //Clicks on the item in the list
Wait(1000 + Random(1000));
If FindColorTolerance(x, y, Colour, 102, 95, 144, 130, 20) then
begin
break;
end else
writeln('Could not detect the items colour in the item slot');
end;
If not FindColorTolerance(x, y, Colour, 102, 95, 144, 130, 20) then
begin
TerminateScript;
end;
SetQuantity(1);
SetPrice(1, Percentage, 0);
MarkTime(c)
While not InGE do
begin
Wait(500);
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen');
TerminateScript;
end;
end;
While not GEFinishedAt(Spot) do //Waits for the offer to complete
begin
Wait(500 + Random(500));
end;
If (GEFinishedAt(Spot)) then
For i := 0 to 5 do
begin
If isBuyOpen then
begin
break;
end else
begin
Mouse(103, 139, 20, 20, mouse_Left); // Click on the trade offer once complete
Wait(1500 + random(1000));
end;
end;
If not isBuyOpen then
begin
Writeln('Could not get to the collection screen');
TerminateScript;
end;
BoughtFor1 := BoughtFor
SellPrice := BoughtFor1 - 1;
ItemCollection;
result := SellPrice
end;
function FindLow(Spot, Colour: integer; Percentage: extended): integer;
var
c, x, y, i: integer;
begin
While not isInGE do
begin
isInGE;
end;
For i := 0 to 4 do
begin
If GEIsSpotFree(Spot) then
begin
break;
end else
begin
GERecoverAtEx(Spot, True);
end;
end;
For i := 0 to 2 do
begin
If isSellOpen then
begin
break;
end;
If InGE then
begin
GEBuyOrSellAtEx(1, Spot);
Wait(500 + Random(500));
end else
begin
writeln('Not in GE');
end;
end;
If not isSellOpen then
begin
Writeln('Could not get the buying screen open');
TerminateScript;
end;
If not (FindColorTolerance(x, y, Colour, 103, 95, 143, 129, 20)) then //looks for the colour in the item icon thing
For i := 0 to 3 do
begin
If FindColorTolerance(x, y, Colour, MIX1, MIY1, MIX2, MIY2, 20) then
begin
If FindColorTolerance(x, y, Colour, 103, 95, 143, 129, 20) then
begin
break;
end;
Mouse(x, y, 5, 10, mouse_Left); //Clicks on the item's coords
Wait(200 + Random(250));
end;
end;
SetQuantity(1);
SetPrice(0, Percentage, 0);
MarkTime(c)
While not InGE do
begin
Wait(500);
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen');
TerminateScript;
end;
end;
While not GEFinishedAt(Spot) do //Waits for the offer to complete
begin
Wait(500 + Random(500));
end;
If (GEFinishedAt(Spot)) and (FindColorTolerance(x, y, 1999423, 38, 162, 169, 180, 20)) then
For i := 0 to 5 do
begin
If isSellOpen then
begin
break;
end else
begin
Mouse(103, 139, 20, 20, mouse_Left); // Click on the trade offer once complete
Wait(1500 + random(1000));
end;
end;
If not isSellOpen then
begin
Writeln('Could not get to the collection screen');
TerminateScript;
end;
SoldFor1 := SoldFor
BuyPrice := SoldFor1 + 1;
ItemCollection;
result := BuyPrice
end;
Function FlipBuyPrice(Spot, Limit, Colour: integer; Item: string): integer;
var
x, y, i, n, c, i1, x1, y1: integer;
isFound: boolean;
begin
While not isInGE do
begin
isInGE;
end;
For i := 0 to 4 do
begin
If GEIsSpotFree(Spot) then
begin
break;
end else
begin
GERecoverAtEx(Spot, True);
end;
end;
For i := 0 to 2 do
begin
If isBuyOpen then
begin
break;
end;
If InGE then
begin
GEBuyOrSellAtEx(0, Spot);
Wait(500 + Random(500));
end else
begin
writeln('Not in GE');
end;
end;
If not isBuyOpen then
begin
Writeln('Could not get the buying screen open');
TerminateScript;
end;
For i := 0 to 2 do
begin
If isItemSearchOpen then
begin
break;
end else
begin
Mouse(125, 116, 10, 10, mouse_Left);
Wait(1000 + Random(500));
end;
end;
i1 := 0
While (isFound = False) or (i1 < 6) do
begin
inc(i1)
isFound := False
If not (GetTextAtEx(25, 453, 10, SmallChars, False, False, 0, 10, 16777215, 810, False, tr_AllChars) = '*') then
begin
For i := 0 to 15 do
begin
TypeSendEx('', true);
If (GetTextAtEx(25, 453, 10, SmallChars, False, False, 0, 10, 16777215, 810, False, tr_AllChars) = '*') then
break;
end;
end;
TypeSendEx(Item, true);
Wait(2000 + Random(500));
n := 342
While n < 440 do
begin
If GetTextAtEx(65, n, 10, SmallChars, False, False, 0, 10, 23200, 810, False, tr_AllChars) = Item then
begin
isFound := True
x1 := 65 + 30
y1 := n + 6
Break;
end;
n := n + 16
end;
If isFound = True then
begin
break;
end;
If (n > 440) then
Writeln('Item not found in searchbox.');
end;
If not FindColorTolerance(x, y, Colour, 102, 95, 144, 130, 20) then //looks for the colour in the item icon thing
For i := 0 to 2 do
begin
Mouse(x1, y1, 10, 3, mouse_Left); //Clicks on the item in the list
Wait(1000 + Random(1000));
If FindColorTolerance(x, y, Colour, 102, 95, 144, 130, 20) then
begin
break;
end else
writeln('Could not detect the items colour in the item slot');
TerminateScript;
end;
SetQuantity(Limit);
SetPrice(2, 0, BuyPrice);
MarkTime(c);
While not InGE do
begin
Wait(500);
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen1');
TerminateScript;
end;
end;
While not GEFinishedAt(Spot) do //Waits for the offer to complete
begin
Wait(500 + Random(500));
If not LoggedIn then
LoginPlayer;
isInGE;
end;
If (GEFinishedAt(Spot)) and (FindColorTolerance(x, y, 1999423, 38, 162, 169, 180, 20)) then
For i := 0 to 5 do
begin
If isBuyOpen then
begin
break;
end else
begin
Mouse(103, 139, 20, 20, mouse_Left); // Click on the trade offer once complete
Wait(1500 + random(1000));
end;
end;
If not isBuyOpen then
begin
Writeln('Could not get to the collection screen');
TerminateScript;
end;
Result := (BuyPrice * Limit);
ItemCollection;
MarkTime(c)
While not InGE and isBuyOpen do
begin
Wait(500 + Random(500));
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen2');
TerminateScript;
end;
end
end;
function FlipSellPrice(Spot, Colour, Limit: integer): integer;
var
x, c, y, i: integer;
begin
While not isInGE do
begin
isInGE;
end;
For i := 0 to 4 do
begin
If GEIsSpotFree(Spot) then
begin
break;
end else
begin
GERecoverAtEx(Spot, True);
end;
end;
For i := 0 to 2 do
begin
If isSellOpen then
begin
break;
end;
If InGE then
begin
GEBuyOrSellAtEx(1, Spot);
Wait(500 + Random(500));
end else
begin
writeln('Not in GE');
end;
end;
If not isSellOpen then
begin
Writeln('Could not get the buying screen open');
TerminateScript;
end;
If not (FindColorTolerance(x, y, Colour, 103, 95, 143, 129, 20)) then //looks for the colour in the item icon thing
For i := 0 to 3 do
begin
If FindColorTolerance(x, y, Colour, MIX1, MIY1, MIX2, MIY2, 20) then
begin
If FindColorTolerance(x, y, Colour, 103, 95, 143, 129, 20) then
begin
break;
end;
Mouse(x, y, 5, 10, mouse_Left); //Clicks on the item's coords
Wait(200 + Random(250));
end;
end;
SetToAll;
SetPrice(2, 0, SellPrice);
MarkTime(c);
While not InGE do
begin
Wait(500);
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen1');
TerminateScript;
end;
end;
While not GEFinishedAt(Spot) do //Waits for the offer to complete
begin
Wait(500 + Random(500));
If not LoggedIn then
LoginPlayer;
isInGE;
end;
If (GEFinishedAt(Spot)) and (FindColorTolerance(x, y, 1999423, 38, 162, 169, 180, 20)) then
For i := 0 to 5 do
begin
If isSellOpen then
begin
break;
end else
begin
Mouse(103, 139, 20, 20, mouse_Left); // Click on the trade offer once complete
Wait(1500 + random(1000));
end;
end;
If not isSellOpen then
begin
Writeln('Could not get to the collection screen');
TerminateScript;
end;
Result := (SellPrice * Limit);
ItemCollection;
MarkTime(c)
While not InGE and isSellOpen do
begin
Wait(500 + Random(500));
If TimeFromMark(c) > 30000 then
begin
Writeln('Could not get to the GE main screen4');
TerminateScript;
end;
end
end;
Function ifBuyPrice: boolean;
begin
If ((FindHigh(ITEM1_SPOT, ITEM1_COLOUR, ITEM1_PERCENTAGEABOVE, ITEM1_Name) - FindLow(ITEM1_SPOT, ITEM1_COLOUR, ITEM1_PERCENTAGEBELOW)) > 0) then
begin
result := true;
incprofit := true;
end else
result := false;
incprofit := false;
end;
procedure Progress_Report;
begin
ClearDebug;
Writeln('[---------------HT BaaFlys Grand Exchange Flipper---------------|');
Writeln('[Ran for: ' + TimeRunning + ']');
Writeln('[Total profit: ' + (IntToStr(Profit2)) + ']');
Writeln('[Profit per hour: ' + FloatToStr((3600 * Profit2) / (GetTimeRunning / 1000)) + ']');
end;
procedure Loop;
begin
repeat
If ifBuyPrice then
begin
writeln('Profitable - proceeding to buy')
FlipBuyPrice(ITEM1_SPOT, ITEM1_LIMIT, ITEM1_COLOUR, ITEM1_NAME);
FlipSellPrice(ITEM1_SPOT, ITEM1_COLOUR, ITEM1_LIMIT);
end else
begin
writeln('No profit - breaking');
Wait(round((ITEM1_REFRESH * 60000) + Random(5000)));
end;
Profit := ((SellPrice * ITEM1_LIMIT) - (BuyPrice * ITEM1_LIMIT)) - (BoughtFor1 - SoldFor1);
IncEx(Profit2, Profit);
Progress_Report;
until not LoggedIn
end;
begin
ClearDebug;
SetupSRL;
MouseSpeed := 10;
Smart_Server := 120;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
Profit := 0;
DeclarePlayers;
If not Loggedin then
begin
LoginPlayer;
Wait(4000 + Random(1000));
end;
Loop;
writeln('Logged out. Stopping script.');
TerminateScript;
end.