Log in

View Full Version : Help with script



alexmeh
05-04-2012, 09:22 PM
I'm trying to make my first script, and i got a lot of help. I got the whole skeleton for the script and just needed to fill things in. The script is a wine drinker and I need a way to click all the 28 wines in the inventory. When I try the script now it only opens the bank and close it again.

here is the code I have now:

Program WineDrinker;
{$DEFINE SMART} {Tells The Script To Open Smart Client}
{$i SRL/srl.simba}

Var
X, Y, wine: Integer; // Variables

Procedure CallThangs;
Begin
wine := DTMFromString('mrAAAAHic42BgYOAGYlYGCGADYjEglgRiYS Q5DihfEirPBcRMUD1dhtpQHnZsxIAfMBLAMAAA3PEB9Q==');
End;


Procedure FreeThangs;
Begin
FreeDTM(wine);
End;



Procedure OpenmyBank; {Going To Give You A Easy Shell}
Begin
If (FindObjCustom(X, Y, ['Bank', 'booth'], [5862270, 5928063, 5928320, 5862527], 10)) Then
Begin
ClickMouse2(False)
Wait(150 + Random(50));
ChooseOption('Bank'); {The Option Uptext Here}
While(IsMoving) Do
wait(2000+random(100)); {2 Second Wait For Bankscreen To Show}
End;
End;


{In FindDTM(X,Y,MSX1 > The MSX1 + Rest Stands for Mainscreen Coords}
Procedure WithdrawWines; {This Will Take Them out of Bank}
Begin
If (Bankscreen) Then
Begin
If FindDTM(wine, X, Y, MSX1, MSY1, MSX2, MSY2) Then
Wait(150 + Random(50)); {To Give It Time To Move Mouse Over Object}
ClickMouse2(False); {False Means Right Click, So Were Finding The Wines Then Right Clicking Them}
Wait(150 + Random(50)); {This Gives It Time For The UpText To Show}
ChooseOption('Withdraw-All'); {After Finding The Object And Right Clicking This Will Choose The Option 'Withdraw-All'}
End;
End;


{Cant Remember How To Do The Case Here So Ask On Forums}
Procedure DrinkWines; {Handles Drinking The Wines}
Begin {Notice These are MIX? > I Stands For Inventory}
Repeat
If FindDTM(wine, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
If (IsUpText('Drink')) Then
Begin
wait(400 + random(150));
ClickMouse2(False);
Wait(150 + Random(100));
ChooseOption('Drink');
End;
End;
Until Not(FindDTM(wine, x, y, MIX1, MIY1, MIX2, MIY2));
End;


Procedure HandleBanking;
Begin
OpenmyBank;
Deposit(1, 28, True);{Simple Deposit SRL Includes Function Will Deposit All Items In Invetory}
WithdrawWines; {Calls The Procedure To Withdraw Wines}
CloseBank;
End;



Begin
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;

SetupSRL;
AddOnTerminate('FreeThangs')
SetAngle(SRL_ANGLE_HIGH)
Repeat
HandleBanking;
DrinkWines;
Until(False);
FreeThangs;
Terminatescript();
End.

The notes are to help me because i'm new to scripting.
Thanks

Alexmeh

tehq
05-04-2012, 09:26 PM
The first thing I noticed was you don't move the mouse in your WithdrawWines or DrinkWines procedures

Abu
05-04-2012, 09:51 PM
Before using ClickMouse2, you must do MMouse(x, y, 0, 0) - this will move the mouse to where you want before clicking.

To save from actually having to do this, you could just use Mouse(x, y, 0, 0, False) which moves the mouse and clicks :)

Rich
05-04-2012, 09:59 PM
Before using ClickMouse2, you must do MMouse(x, y, 0, 0) - this will move the mouse to where you want before clicking.

To save from actually having to do this, you could just use Mouse(x, y, 0, 0, False) which moves the mouse and clicks :)Without randomness?

alexmeh
05-04-2012, 10:43 PM
i now got this, but it also doesn't withraw the wines.


Program WineDrinker;
{$DEFINE SMART}
{$i SRL/srl.simba}

Var
X, Y, wine: Integer;

Procedure CallThangs;
Begin
wine := DTMFromString('mrAAAAHic42BgYOAGYlYGCGADYjEglgRiYS Q5DihfEirPBcRMUD1dhtpQHnZsxIAfMBLAMAAA3PEB9Q==');
End;


Procedure FreeThangs;
Begin
FreeDTM(wine);
End;


Procedure OpenmyBank;
Begin
If (FindObjCustom(X, Y, ['Bank', 'booth'], [5862270, 5928063, 5928320, 5862527], 10)) Then
Begin
Mouse(x, y, 5, 5, False)
Wait(150 + Random(50));
ChooseOption('Bank');
While(IsMoving) Do
wait(2000+random(100));
End;
End;


Procedure WithdrawWines;
Begin
If (Bankscreen) Then
Begin
If FindDTM(wine, X, Y, MSX1, MSY1, MSX2, MSY2) Then
Mouse(x, y, 5, 5, False);
ChooseOption('Withdraw-All');
End;
End;


Procedure DrinkWines;
Begin
Repeat
If FindDTM(wine, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
Mouse(x, y, 5, 5, True)
End;
Until Not(FindDTM(wine, x, y, MIX1, MIY1, MIX2, MIY2));
End;


Procedure HandleBanking;
Begin
OpenmyBank;
Deposit(1, 28, True);
WithdrawWines;
CloseBank;
End;



Begin
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;

SetupSRL;
AddOnTerminate('FreeThangs')
SetAngle(SRL_ANGLE_HIGH)
Repeat
HandleBanking;
DrinkWines;
Until(False);
FreeThangs;
Terminatescript();
End.

Abu
05-04-2012, 10:51 PM
Without randomness?

Ahah lol my bad. I'm currently working on a Mining Script where if I add randomness it may miss the ore.

Oh well :p

Google
05-05-2012, 12:01 AM
Procedure WithdrawWines;
Begin
If (Bankscreen) Then
Begin
If FindDTM(wine, X, Y, MSX1, MSY1, MSX2, MSY2) Then
WriteLn('We Found the Wine'); // to see if it finds your DTM
Begin // Missing the Begin
Mouse(x, y, 5, 5, False);
Wait(75 + Random(15)); // also would just give it a small wait for the uptext to show.
ChooseOption('Withdraw-All');
End;
End;
End;