SRL Archive - Reflection Development

R_GetCurrentTab


Bad Boy JH

2010-12-06 07:32:16

function R_GetCurrentTab: Integer;
var
I, ChildID: Integer;
begin
for I := 98 to 105 do
if GetInterfaceComponentTextureID(548, I) <> -1 then
ChildID := I;
for I := 128 to 135 do
if GetInterfaceComponentTextureID(548, I) <> -1 then
ChildID := I;
{ALTERNATIVE
for I := 98 to 105 do
begin
if GetInterfaceComponentTextureID(548, I) <> -1 then
ChildID := I;
if GetInterfaceComponentTextureID(548, I + 30) <> -1 then
ChildID := I + 30;
end;
}
case ChildID of
128 : Result := tab_Combat;
129 : Result := tab_Stats;
130 : Result := tab_Quest;
131 : Result := tab_Diary;
132 : Result := tab_Inv;
133 : Result := tab_Equip;
134 : Result := tab_Prayer;
135 : Result := tab_Magic;
98 : Result := tab_Objectives; //don't know if you guys plan on deleting this variable or not
99 : Result := tab_Friends;
100 : Result := tab_Ignore;
101 : Result := tab_Clan;
102 : Result := tab_Options;
103 : Result := tab_Emotes;
104 : Result := tab_Music;
105 : Result := tab_Notes;
0 : Result := tab_LogOut;
end;
end;

Shuttleu

2010-12-06 08:23:15

looks nice
maybe add

else
Writeln('Unable to detect tab');

~shut

Cstrike

2010-12-06 10:29:29

This is what I created, I'm going to compare them and hopefully we can use yours as it is way more efficient than this:

{------------------------------------------------------------------------------]
| Gametab Functions |
[------------------------------------------------------------------------------]
| - All gametab (interface like tabs, HP, prayer...etc) go here |
| |
| |
| |
[------------------------------------------------------------------------------}

const
I_Tab_Active = 1836; // Active texture ID
I_Tab_GametabInterface = 548;

I_Stats_Interface = 320;

{===============================================================================
function I_OpenCombatTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenCombatTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 126) = I_Tab_Active);
if Result then Exit;
Mouse (528, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 126) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 126) = I_Tab_Active);
end;

{===============================================================================
function I_OpenStatsTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenStatsTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 127) = I_Tab_Active);
if Result then Exit;
Mouse (554, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 127) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 127) = I_Tab_Active);
end;

{===============================================================================
function I_OpenQuestTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenQuestTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 128) = I_Tab_Active);
if Result then Exit;
Mouse (584, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 128) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 128) = I_Tab_Active);
end;

{===============================================================================
function I_OpenAchievementTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenAchievementTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 129) = I_Tab_Active);
if Result then Exit;
Mouse (614, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 129) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 129) = I_Tab_Active);
end;

{===============================================================================
function I_OpenInventoryTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenInventoryTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 130) = I_Tab_Active);
if Result then Exit;
Mouse (644, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 130) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 130) = I_Tab_Active);
end;

{===============================================================================
function I_OpenEquipmentTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenEquipmentTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 131) = I_Tab_Active);
if Result then Exit;
Mouse (674, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 131) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 131) = I_Tab_Active);
end;

{===============================================================================
function I_OpenPrayerTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenPrayerTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 132) = I_Tab_Active);
if Result then Exit;
Mouse (703, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 132) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 132) = I_Tab_Active);
end;

{===============================================================================
function I_OpenMagicTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenMagicTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 133) = I_Tab_Active);
if Result then Exit;
Mouse (734, 172, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 133) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 133) = I_Tab_Active);
end;

{===============================================================================
function I_OpenObjectiveTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenObjectiveTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 96) = I_Tab_Active);
if Result then Exit;
Mouse (523, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 96) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 96) = I_Tab_Active);
end;

{===============================================================================
function I_OpenFriendsTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenFriendsTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 97) = I_Tab_Active);
if Result then Exit;
Mouse (553, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 97) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 97) = I_Tab_Active);
end;

{===============================================================================
function I_OpenIgnoreTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenIgnoreTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 98) = I_Tab_Active);
if Result then Exit;
Mouse (583, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 98) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 98) = I_Tab_Active);
end;

{===============================================================================
function I_OpenClanTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenClanTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 99) = I_Tab_Active);
if Result then Exit;
Mouse (613, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 99) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 99) = I_Tab_Active);
end;

{===============================================================================
function I_OpenSettingsTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenSettingsTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 100) = I_Tab_Active);
if Result then Exit;
Mouse (643, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 100) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 100) = I_Tab_Active);
end;

{===============================================================================
function I_OpenEmoteTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenEmoteTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 101) = I_Tab_Active);
if Result then Exit;
Mouse (673, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 101) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 101) = I_Tab_Active);
end;

{===============================================================================
function I_OpenMusicTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenMusicTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 102) = I_Tab_Active);
if Result then Exit;
Mouse (703, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 102) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 102) = I_Tab_Active);
end;

{===============================================================================
function I_OpenNotesTab : Boolean;
By: Cstrike
Description: Returns true if tab is open or if it can open it.
===============================================================================}
function I_OpenNotesTab : Boolean;
var
t : Integer;
begin
if not I_LoggedIn then Exit;
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 103) = I_Tab_Active);
if Result then Exit;
Mouse (733, 467, 20, 28, true);
MarkTime (t);
repeat
wait (25+random(15));
until (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 103) = I_Tab_Active) or (TimeFromMark(t) < 5000)
Result := (GetInterfaceComponentTextureID(I_Tab_GametabInterface, 103) = I_Tab_Active);
end;

{===============================================================================
function I_OpenTab (TabName : String) : Boolean;
By: Cstrike
Description: Returns true if tab you specify is opened.
===============================================================================}
function I_OpenTab (TabName : String) : Boolean;
begin
if not I_LoggedIn then Exit;
Result := False;
case lowercase(TabName) of
'combat', 'fight', 'fighting': Result := I_OpenCombatTab;
'stats', 'stat', 'player stats', 'char': Result := I_OpenStatsTab;
'quest', 'quests': Result := I_OpenQuestTab;
'achievement', 'achievements': Result := I_OpenAchievementTab;
'inventory', 'inv', 'invi': Result := I_OpenInventoryTab;
'equipment', 'equip', 'armor', 'weapons': Result := I_OpenEquipmentTab;
'prayer', 'prayers': Result := I_OpenPrayerTab;
'magic', 'mage': Result := I_OpenMagicTab;
'objective', 'objectives': Result := I_OpenObjectiveTab;
'friends', 'friend', 'friend list', 'friends list': Result := I_OpenFriendsTab;
'ignore', 'ignore list': Result := I_OpenIgnoreTab;
'clan', 'clans', 'clan chat': Result := I_OpenClanTab;
'settings', 'setting': Result := I_OpenSettingsTab;
'emote', 'emotes': Result := I_OpenEmoteTab;
'music': Result := I_OpenMusicTab;
'notes', 'note': Result := I_OpenNotesTab;
end;
end;

{===============================================================================
function I_GetTempLevel (SkillName : String) : Integer;
By: Cstrike
Description: Returns true if tab you specify is opened.
===============================================================================}
function I_GetTempLevel (SkillName : String) : Integer;
begin
Result := -1;
if not I_LoggedIn then Exit;
if I_OpenStatsTab then
begin
case lowercase(SkillName) of
'attack', 'att': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 196));
'defence', 'defense', 'def': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 24));
'strength': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 7));
'hitpoints', 'hp', 'constitution': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 189));
'range', 'ranged': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 48));
'mage', 'magic': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 89));
'prayer', 'pray': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 72));
'runecrafting', 'runecraft', 'rc': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 106));
'construction', 'cons', 'con': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 130));
'dung', 'dungeon', 'dungeoneering': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 154));
'agility', 'agil': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 15));
'herb', 'herblore', 'herblaw': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 32));
'thieving', 'thief': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 56));
'crafting', 'craft': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 80));
'fletching', 'fletch': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 97));
'slayer', 'slay', 'slaying': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 114));
'hunter', 'hunt': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 138));
'mining', 'mine': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 182));
'smithing', 'smith', 'smelt': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 175));
'fishing', 'fish': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 40));
'cooking', 'cook': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 64));
'firemaking', 'fm', 'fire': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 168));
'woodcutting', 'wc', 'wood', 'woodcut': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 161));
'farming', 'farm': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 122));
'summoning', 'summon': Result := StrToInt(GetInterfaceComponentText(I_Stats_Interface, 146));
end;
end;
end;

EDIT: Yours looks better than mine, going to commit this today.
Awesome job, you're cranking out solid upgrades like no tomorrow

Bad Boy JH

2010-12-06 19:52:31

some people get addicted to drugs, I get addicted to SRL, go figure..