DrChill
11-29-2012, 02:58 PM
This is my first public script Snippet, it checks if chat is open, and enables the action bar if it isn't. I'm not sure how kosher it is to use functions from someone's script, I'm from the OpenSource community, and there it is normal to borrow bits and pieces from others' script (also anti-leech would be widely condemned there ;) ).
I started out modifying Laimonas's function (http://villavu.com/forum/showthread.php?t=92787), then I kinda re-wrote it all. I observed a problem, PressKey is apparently made for typing so they make sure the chat is open, we need the opposite. Also, every time you go to the bank the action bar gets closed out, making this necessary. And finally slots are re-arrangeable so you have to be able to choose different keys for different slots.
// Borrowed from Flight's Barbarian Fly Fisher
function EnableActionBar: Boolean;
var
X,Y,i: Integer;
begin
Result := False;
for i:=1 to 5 do
if (FindText(x,y,ToStr(i),UpChars,490,300,505,315) and (not Result)) then
Result := True;
if not Result then
begin
MMouse(507,332, 2, 2);
if WaitUptext('Expand', 400) then
ClickMouse2(mouse_left);
for i:=1 to 5 do
if FindText(x,y,ToStr(i),UpChars,490,300,505,315) then
Result := True;
Wait(RandomRange(750, 1200));
end;
end;
(*
UseActionKey
-------------
function UseActionKey(keyString:string);
Example: UseActionKey('1'); // Use slot 1
by DrChill
*)
procedure UseActionKey(keyString : Char);
begin
if PlayerChatActive then
TypeByte(VK_ENTER);
if EnableActionBar then
begin
SendKeys(keyString, 50+Random(51), 30+Random(30));
end
end;
Enjoy, and feel free to criticize, I'm new to Pascal, Botting, and the SRL community in general :).
I started out modifying Laimonas's function (http://villavu.com/forum/showthread.php?t=92787), then I kinda re-wrote it all. I observed a problem, PressKey is apparently made for typing so they make sure the chat is open, we need the opposite. Also, every time you go to the bank the action bar gets closed out, making this necessary. And finally slots are re-arrangeable so you have to be able to choose different keys for different slots.
// Borrowed from Flight's Barbarian Fly Fisher
function EnableActionBar: Boolean;
var
X,Y,i: Integer;
begin
Result := False;
for i:=1 to 5 do
if (FindText(x,y,ToStr(i),UpChars,490,300,505,315) and (not Result)) then
Result := True;
if not Result then
begin
MMouse(507,332, 2, 2);
if WaitUptext('Expand', 400) then
ClickMouse2(mouse_left);
for i:=1 to 5 do
if FindText(x,y,ToStr(i),UpChars,490,300,505,315) then
Result := True;
Wait(RandomRange(750, 1200));
end;
end;
(*
UseActionKey
-------------
function UseActionKey(keyString:string);
Example: UseActionKey('1'); // Use slot 1
by DrChill
*)
procedure UseActionKey(keyString : Char);
begin
if PlayerChatActive then
TypeByte(VK_ENTER);
if EnableActionBar then
begin
SendKeys(keyString, 50+Random(51), 30+Random(30));
end
end;
Enjoy, and feel free to criticize, I'm new to Pascal, Botting, and the SRL community in general :).