traveler
2010-12-07 21:32:52
Just thought i would make a function like the srl's choose option. What this function does, it searches for all the text in the array.
for example:
if your searching for 'Use-quickly Bank Booth'
You input this into the function ['booth','quickly','Use'] and it will find the first menu option, which in this case would be 'Use-quickly Bank Booth' and it will select it.
If it can not find all the options inputted, it will select the first option matching one of the inputed strings.
for example:
if your searching for 'Use-quickly Bank Booth'
You input this into the function ['booth','quickly','Use'] and it will find the first menu option, which in this case would be 'Use-quickly Bank Booth' and it will select it.
If it can not find all the options inputted, it will select the first option matching one of the inputed strings.
{*******************************************************************************
function R_ChooseOptionEx(Options: TStringArray): Boolean;
By: traveler - moddified from R_ChooseOptionMulti
Description: Selects the first option that matches all the inputted strings.
If None match, chooses first option with a matching string.
*******************************************************************************}
function R_ChooseOptionEx(Options: TStringArray): Boolean;
var
T, I, I2, xOff, yOff: Integer;
PT: TPoint;
MenuOptions: TStringArray;
begin
Result := False;
if not IsMenuOpen then
begin
MarkTime(T);
while(TimeFromMark(T) < 1000)do
wait(50);
if not IsMenuOpen then
Exit;
end;
PT := Point(SmartGetFieldInt(0, hook_static_MenuX) + 4, SmartGetFieldInt(0, hook_static_MenuY) + 4);
MenuOptions := GetMenuText;
// Cstrike's failsafe
if (high(MenuOptions) < 0) or (high(Options) < 0) then
begin
Writeln('Warning: High array size for MenuOptions/Options is < 0, aborting R_ChooseOptionMulti to prevent crash');
Exit;
end;
for I:=0 to High(MenuOptions) do
begin
for I2:=0 to High(Options) do
begin
if (Pos(Lowercase(Options[I2]),Lowercase(MenuOptions[I])) <= 0) then
Continue;
if (I2 = (High(Options)-1)) then
begin
xOff := RandomRange(4, 4 + Random(Length(MenuOptions[i]) * 4 - 4));
yOff := 21 + (16 * i) + RandomRange(2, 10);
Mouse(PT.x + xOff, PT.y + yOff, 0, 0, True);
Wait(RandomRange(80, 100));
Result := not IsMenuOpen;
Exit;
end;
end;
end;
Result := R_ChooseOptionMulti(Options);
end;