SRL Archive - OSR Help

I need help making my first script. (It makes Chocolate Dust)


Paula_Deen

2011-12-23 23:33:24

Is there a way to make it so the script will deposit the chocolate dust as soon as I'm done crushing the chocolate bars?

Right now, I just have a wait time, and then it'll deposit after the wait time is up (I have this section in bold). Ordinarily, this system would work fine; However, since the user can either use a knife or a pestle and mortar, the wait time would either be too long or too short.
(the pestle and mortar crushes chocolate twice as fast as a knife, btw.)

Also, I'm pretty sure I'm not Freeing my DTM's properly. The script runs fine, but when the script ends, I get an error saying "The following DTMs were not freed: [2]"


Script:
program ChocolateCrusher;

{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i SRL\SRL\Misc\Stats.simba}

var
x, y: Integer;

{YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT!
If You are a /member/, use the pestle and mortar. The pestle and mortar crushes
chocolate twice the speed of a knife.
Free to play people will have to stick with a knife.

IMPORTANT:
Make sure you have your Chocolate Bars in the FIRST bank slot.
The script will end if it is in any other slot.}

Const
Mouse_Speed = 17; // Mouse speed - Higher = Faster. (17 is default)
Members = false; // True = Members World. False = Free World.
Version = '1.0 Beta';
NumbOfPlayers = 1; //How many players you are using.
StartPlayer = 0; //Player to start with. (0 = first character)

// YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT

procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['xp', 'oins', 'ostume', 'mote'];

with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Pin := ''; //Bank Pin. (Leave blank if you do not have a bank pin.)
Loc := 'vwb'; //Banking Location (See below)
Active := True;
end;
// YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT!
//
// Banking Locations:
// 'vwb' = Varrock West Bank
// 'veb' = Varrock East Bank
// 'fwb' = Falador West Bank
// 'feb' = Falador East Bank
// 'db' = Draynor Bank
// 'akb' = Al-Kharid Bank
//
end;


Procedure Antiban;
Begin
Case Random (30) of
0: Begin SleepAndMoveMouse(6000 + Random(750)); End;
1: Begin GameTab(tab_Inv) ExamineInv; GameTab(28); End;
2: Begin RandomAngle(1); End;
3: Begin GameTab(Tab_Stats); Wait(3000 + Random(400)); GameTab(28); End;
4: Begin GameTab(tab_Stats) HoverSkill('random', False); GameTab(28); End;
End;
End;


procedure AntiRandoms;
begin
FindNormalRandoms;
LampSkill := 'random'
end;


procedure WithdrawChoc;
begin
AntiRandoms;
if (PinScreen) then
InPin(Players[CurrentPlayer].Pin);
if (BankScreen) then
DepositAll;
WriteLn(' -Depositing Chocolate Dust.');
Wait(400 + Random(300));
Withdraw(0, 0, 28);
WriteLn('-Withdrawing Chocolate Bars.');
Wait(200 + Random(200));
CloseBank;
end;

procedure CrushChoc;
var
chocbar, chocdust : Integer;
begin
begin
chocbar := DTMFromString('mwQAAAHic42RgYOABYlYgFgFiQSBmY4AAkLgklOYAYgEomwmqBsQWBmJ2qHpfHXGoLG78n4EwYCQCwwEAFn4CcQ==');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 7, 7, False)
else
begin
wait(1000);
WriteLn('Could not find Chocolate Bar. Trying again...');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 7, 7, False)
else
begin
wait(1000);
WriteLn('Could not find Chocolate Bar. Trying again...');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 7, 7, False)
else
begin
wait(1000);
WriteLn('Could not find Chocolate Bar. Logging out.');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 7, 7, False);
Logout;
TerminateScript;
end;
end;
end;
ChooseOption('Powder')
FreeDTM(chocbar);
end;

begin
wait(1000)
[B]chocdust := DTMFromString('m1gAAAHic42JgYOAEYnYg5gNiZiAWAGIOBgjgBmJ+IBaFqgHJMwIxLxBzQeW4oGrZgJgViO1VhIEkE0H8n4E4wEgkRgAAHfUCSg==');
if FindDTM(chocdust, x, y, MCX1, MCY1, MCX2, MCY2) then
Mouse(x, y, 22, 23, True);
WriteLn(' -Crushing Chocolate Bars.');
Wait(1500 + Random(2000));
Antiban;
AntiRandoms;
Wait(11000 + Random(3000));
FreeDTM(chocdust);[/B]
end;
end;





begin
Smart_Server := 10;
Smart_Members := Members;
SetupSRL;
DeclarePlayers;
MouseSpeed := Mouse_Speed;
LoginPlayer;

repeat
repeat
OpenBank(Players[CurrentPlayer].Loc, True, True);
WithdrawChoc;
CrushChoc;
until (not LoggedIn);
until False;
end.

Also, should I release this?
It's a good money making technique, but do you think it would have too much of a negative impact on the economy?

YoHoJo

2011-12-23 23:35:53

HOLY COCKBALLS DUDE!
You left user/pass in script. you are SO LUCKY I got to it first and changed it! Be careful next time!
PMing you new pass now!
Also, put SIMBA tags around script please, not quote tags

YoHoJo

2011-12-23 23:38:30

HOLY SHIT!
Pretty nice account dude
[20:37] YoHoJo: 51M in pouch
[20:37] YoHoJo: 1523 total
[20:37] YoHoJo: 92str
[20:37] YoHoJo: 93magic
[20:37] YoHoJo: 99cook
[20:37] YoHoJo: 99fletch
[20:37] YoHoJo: 99theiv
[20:37] YoHoJo: 90wc

You are very very lucky I got that first, I bet SO MANY losers here would have stolen it….

Paula_Deen

2011-12-23 23:40:49

Omgggg

thanks!!!!!!

Paula_Deen

2011-12-23 23:42:11

You're my hero!!

THANKS!!
I can't thank you enough! :)

Oh, and thanks for the awesome video tutorials!
They inspired me! :)

YoHoJo

2011-12-23 23:43:32

Glad to hear it! Many people have, and I love the feeling of helping out so many!
That's a pretty damn nice account you got there, not too shabby, I can't imagine the stress and anger you would feel if someone nabbed it! Glad it's safe!

Paula_Deen

2011-12-23 23:55:01

And thanks for the complement! :)
I'm working on 99 magic … well, I'm letting Simba do it for me. ;)

Yeah, I was about to rage quit if I'd lose the account. :p
I had that account for around 6 years now without anyone ever hacking it.
(I'm a off and on RSer … I only recently started playing again. This community may change that though! :D)

So, any help with the script? :)

YoHoJo

2011-12-23 23:59:48

Just glanced.
Since you're using the DTMs so often I wouldn't even bother freeing them.
Just load the ONCE ONLY, and never free.

As for deposit.
Have script search for DTM of regular (non crushed) chocolate in inventory, and when it's not found, that means you've crushed it all. OR have it search for crushed chocolate in your last inventory slot (assuming there is one there) and if one is you are done crushing.

Paula_Deen

2011-12-24 00:10:01

And that's a really good idea! Why didn't I think of that? :p

Oh, and is Edgeville banking broken?
I tried it yesterday, and it wouldn't work. :/

YoHoJo

2011-12-24 00:14:53

Might be, report it in bug section.
Check bank.simba and see if it's even a valid option.
Most people end up writing their own banking

Paula_Deen

2011-12-24 00:35:03

"The following DTMs were not freed: [SRL - Lamp bitmap, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105]"

I don't think I'm understanding what you mean by saying to load them only once…

YoHoJo

2011-12-24 00:35:45

That's normal.
Happens any time you stop any SRL scripts prematurely.

As for load once,

Have
Procedure LoadDTMs;
Bein
bla bla my dtms
End;

and only call the procedure ONCE, like after setupsrl or something.

Paula_Deen

2011-12-24 01:40:00

Okay, so I have the script searching for Chocolate Bars in my inventory, but how would I tell the script to end that loop and continue on with the banking process?
Right now it's searching for the chocolate bars, but it does nothing when it can't find them.
This is probably going to be simpler than I'm making it. :p

I can't use the latter method you suggested because it would just create an infinite loop if there was no item in the last inventory spot … or would it… hm…

cause

2011-12-25 23:19:02

Hey there, if you wanted to not change too much stuff in your script you could just use a variable as your wait time and have a const set to whether or not you use a knife or pestle.

So you'd have a procedure that says
if (usingKnife=true) then
begin
waitvariable:=11000;
end
else
begin
waitvariable:=20000;
end;

Wait(waitvariable+ Random(2000));

Kyle Undefined

2011-12-26 11:36:07

Wow, that's an impressive account. Thankfully YoHoJo is an amazing person :)