SCAR Code:
{*******************************************************************************
function GameTab(Tab: integer): boolean;
By: ZephyrsFury
Description: Switches to a specific game tab.
const
tab_Combat = 21;
tab_Stats = 22;
tab_Quest = 23;
tab_Diary = 24;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;
tab_Objectives = 29;
tab_Friends = 30;
tab_Ignore = 31;
tab_Clan = 32;
tab_Options = 33;
tab_Emotes = 34;
tab_Music = 35;
tab_Notes = 36;
tab_LogOut = 37;
*******************************************************************************}
function GameTab(Tab: integer): boolean;
var
tP: TPoint;
T, Tries: integer;
begin
if (Tab < 20) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please update your script.', warn_AllVersions);
Exit;
end;
if (not (InRange(Tab, Tab_Combat, Tab_LogOut))) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_AllVersions);
Exit;
end;
Result := (GetCurrentTab = Tab);
if (Result) then
Exit;
if (TabExists(Tab)) then
begin
tP := Point((Tab - 21) mod 8 * 30 + RandomRange(527, 545), (Tab - 21) div 8 * 298 + RandomRange(177, 197));
if (Tab = tab_LogOut) then
tP := Point(RandomRange(747, 760), RandomRange(3, 18));
Tries := 0;
while (not Result) and (Tries < 3) do
begin
Mouse(tP.X, tP.Y, 0, 0, True);
T := GetSystemTime;
while (not Result) and (GetSystemTime - T < 2000) do
begin
Result := (GetCurrentTab = Tab);
Wait(100 + Random(100));
end;
Inc(Tries);
end;
end else
SRL_Warn('GameTab', 'GameTab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_Notice);
end;