SRL Archive - OSR Help

My Official Help Thread


King

2012-12-02 13:46:32

Im going to use this thread to ask for help from now on :P

Im making a beer buying script for the varrock tavern( IRL friends request), I have walking down, made custom SPS maps and using several failsafes for walking, teleporting getting lost ect(loadstone, radial walk ect.. not incorporated yet)

Problem: I'm trying to use SendKeys(); and it does not appear to be working, is there currently a problem with them? Can someone show an example of them working? I am going to use them for the action bar, space bar and the number one to bypass the chat (clicking)

Example from my script:
Procedure BuyBeer;
Begin
ClickBartender;
If FindNPCChatText('yer', nothing) then
begin
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
end;
end;

Problem #2: I tried to use FindNPCChatText('yer', nothing) in several places including above and it does not work, I want it to detect the chat and then stop trying to find the bartender

Example of this:
Procedure ClickBartender;
Begin
if AtBar then
Begin
MarkTime(t);
repeat
if FindBartender(X, Y) then
Begin
Mouse(x, y, 0, 0, False)
wait(250+random(50));
ChooseOption('Talk-to');
end;
until((FindNPCChatText('yer', nothing)) or (TimeFromMark(t) > 5000));
end;
end;
The script finds the bartender, but does not detect the text, some suggested only using a localized word and the still did not help.

I will be posting the full script at the bottom of the thread, post any comments/improvements ect. This will not be released, or if it is, it will be anti-leeched or not include banking.

Thanks for reading guys!

Program BeerBuyer;

{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ' '; // Player username
Pass := ' '; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ; //Your bank pin
end;
end;

var
x, y, T: Integer;

Procedure Login;

begin
ClearDebug;
{$IFDEF SMART}
{$IFDEF SRLKING}
Smart_Server := 10;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ELSE}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
{$ENDIF}
DeclarePlayers;
LoginPlayer;
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);
end;

procedure Antiban;
begin
if not LoggedIn then LoginPlayer;
Wait(250+random(50));
if not LoggedIn then Exit;
FindNormalRandoms;
case Random(90) of
2: PickUpMouse;
3: RandomMovement;
4: BoredHuman;
5: ExamineInv;
7: SetAngle(SRL_ANGLE_HIGH);
8: Wait(5000+random(2000));
end;
end;

Procedure WalkToBar;
Var
ToBar:TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE,['Beer_Map']);
ToBar := [Point(98, 76), Point(98, 86), Point(98, 98), Point(99, 105), Point(117, 106), Point(136, 107), Point(146, 108), Point(156, 108), Point(176, 109), Point(182, 113), Point(194, 120), Point(197, 128), Point(200, 141), Point(204, 151), Point(205, 159), Point(203, 174), Point(204, 186), Point(204, 211), Point(205, 227), Point(205, 245), Point(211, 253), Point(230, 253), Point(258, 246)];
SPS_WalkPath(ToBar);
end;

Procedure WalkToBank;
Var
ToBar:TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE,['Beer_Map']);
ToBar := [Point(98, 76), Point(98, 86), Point(98, 98), Point(99, 105), Point(117, 106), Point(136, 107), Point(146, 108), Point(156, 108), Point(176, 109), Point(182, 113), Point(194, 120), Point(197, 128), Point(200, 141), Point(204, 151), Point(205, 159), Point(203, 174), Point(204, 186), Point(204, 211), Point(205, 227), Point(205, 245), Point(211, 253), Point(230, 253), Point(258, 246)];
InvertTPA(ToBar);
SPS_WalkPath(ToBar);

end;

Procedure WalkToBankFromLoadstone;
Var
ToBank:TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE,['11_7','11_6','10_6','10_7','12_7','12_6']);
ToBank := [Point(4681, 3122), Point(4682, 3101), Point(4684, 3081), Point(4683, 3062), Point(4683, 3045), Point(4680, 3026), Point(4680, 3007), Point(4678, 2994), Point(4678, 2974), Point(4674, 2959), Point(4669, 2948), Point(4654, 2937), Point(4640, 2934), Point(4626, 2934), Point(4600, 2933), Point(4588, 2931), Point(4585, 2925), Point(4584, 2917), Point(4584, 2906)];
SPS_WalkPath(ToBank);
end;

//Procedure TeleportToVarrock;
// begin
// end;

Function AtBank:Boolean;
Begin
Wait(250+random(50));
if FindBank('vwb') then
begin
writeln('At the bank');
Result:=True;
end
else
begin
writeln('We are not at the bank Teleporting to varrock and walking there');
Result:=False;
end;
end;

function FindBartender(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.11);

if not(FindColorsTolerance(arP, 6776163, MSX1, MSY1, MSX2, MSY2, 6)) then
begin
Writeln('Cannont find bartender');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 8.72) and (X <= 16.40) and (Y >= 9.22) and (Y <= 17.35) and (Z >= 10.53) and (Z <= 19.95) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;

SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Talk-to')) then
begin;
Result := True;
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
begin
Writeln('Cannot find bartender');
Exit;
end;

GetMousePos(fx, fy);
end;




Procedure ClickBartender;
Begin
if AtBar then
Begin
MarkTime(t);
repeat
if FindBartender(X, Y) then
Begin
Mouse(x, y, 0, 0, False)
wait(250+random(50));
ChooseOption('Talk-to');
end;
until((FindNPCChatText('yer', nothing)) or (TimeFromMark(t) > 5000));
end;
end;

Procedure BuyBeer;
Begin
ClickBartender;
// If FindNPCChatText('yer', nothing) then
begin
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
end;
end;

begin
SRL_SixHourFix := True;
SetupSRL;
DeclarePlayers;
// Repeat
Login;
if not LoggedIn then LoginPlayer;
// If not AtBank then TeleportToVarrock;
// WalkToBar;
repeat
BuyBeer;
until(InvFull);
// WalkToBank;
// DepositBeer;
// Until(not LoggedIn);
end.

Rezozo

2012-12-02 14:06:32

Looks promising to say the least. And nice idea with the help thread in general, I did that with a couple of mine before, all problems fixed :D

Mem+
~Rez

King

2012-12-02 15:21:46

Thankyou!

King

2012-12-03 22:03:38

Script is up and running! It will buy beer and bank it, using TPA's and CTS2 to find the bartender thanks to Footy!

Rezozo

2012-12-03 22:16:33

God, I could never bother myself to do TPA's in scripts, though they help a lot :p
Glad you got it working!
~Rez

Ian

2012-12-03 22:24:27

I'd go with no banking, simply because banking is a good thing to learn. Adding it themselves will hopefully teach them a bit :)

King

2012-12-03 22:42:31

From: Rezozo
God, I could never bother myself to do TPA's in scripts, though they help a lot :p
Glad you got it working!
~Rez


I love TPA's now, they make finding things MUCH easier :spot:

From: BMWxi
I'd go with no banking, simply because banking is a good thing to learn. Adding it themselves will hopefully teach them a bit :)


I think this is what I'm going to go with, I will allow them to pst this in the higher ups completely put together and lower forums with no banking. If anyone respected or who I know can script would like it, feel free to PM me :P

ProJoe

2013-01-04 00:58:37

From: SRLKing

Problem: I'm trying to use SendKeys(); and it does not appear to be working, is there currently a problem with them? Can someone show an example of them working? I am going to use them for the action bar, space bar and the number one to bypass the chat (clicking)

Example from my script:
Procedure BuyBeer;
Begin
ClickBartender;
If FindNPCChatText('yer', nothing) then
begin
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('1', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
SendKeys('SpaceBar', 10, 5);
end;
end;


Hi, not sure if you have this figured out or not yet. I never thought I would be able to help some one else out. I've gotten SendKeys to work in the first script im creating for a rsps, i use it like this:

procedure drop;
begin
SendKeys('::empty', 100, 30);
pressKey(13)//presskey(13) is the return button on your keyboard. If you wanted to use
end; //pressKey for a spacebar, it would be: pressKey(32)

I found this all here http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html

Hope this helps.