SRL Archive - First Scripts

First Script: Chop and Drop *Help*


blulightning

2009-06-26 20:03:04

Thanks to all of the helpful tutorials I've found here, I've created this Chop and Dropper that cuts down trees wherever you happen to be standing. Using a few procedures i've found around the site and editing them to fit my needs, I've added some anitban as well. However, I'm having trouble making it work. It's obviously some noob error on my part, but I was hoping you all here could help me fix it and make it better in general. *phew* here it goes, no flaming my terrible-ness.


program New;
{.include srl/srl.scar}

Procedure NamePlayers;
begin
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';{Added this for randoms :)}
Players[0].Active := True;
end;

function AntiRandoms: Boolean;
begin
Result := False;
if FindFight then
begin
RunAway('n', True, 1, 2000);
Result := True;
end else
Result := FindLamp('woodcutting') or FindNormalRandoms;
end;

procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
FindNormalRandoms;
case Random(8) of
0:
begin
HoverSkill('Woodcutting', false);
Wait(2500+Random(500));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
FindNormalRandoms;
end;
end;
end;

procedure ChopTree;
var x, y: integer;
begin
repeat
FindNormalRandoms;
if FindObj(x, y, 'hop', 2584417, 40) then
Mouse(x, y, 0, 0, false);
ChooseOption('hop');
repeat
wait(400+random(250));
AntiBan;
Until not IsUpText('ree') or (InvFull);
until(InvFull);
end;

procedure RandomDrop(StartSlot, EndSlot : Integer);
var i,s,c : Integer;
AlreadyDropped : Array of Integer;
begin
SetArrayLength(AlreadyDropped, (EndSlot-StartSlot) + 1);
for c:= 0 to High(AlreadyDropped) - 1 do AlreadyDropped[c]:= 0;
repeat
i:= Random((EndSlot-StartSlot) + 1);
if (AlreadyDropped[i] = 0) then
begin
case Random(28) of
0..26: DropItem(AlreadyDropped[i]);
27: begin
MouseItem(AlreadyDropped[i],false);
ChooseOption('xamine');
Wait(100 + Random(200));
DropItem(AlreadyDropped[i]);
end;
end;
AntiRandoms;
AlreadyDropped[i]:= 1;
Inc(s);
Wait(200 + Random(200));
end else
begin
end;
until(s = EndSlot-StartSlot + 1);
end;

begin
SetUpSRL;
ActivateClient;
NamePlayers;
ChopTree;
RandomDrop(1, 28);
end.

Credits to MACRO_FTW for the Antirandom and dialeyj2 for the Dropping procedure
Thanks to 99_ and The Man, and Griff for helping me learn to script the whole thing out

Dynamite

2009-06-26 20:07:21

Could you give us the error and where you think it goes wrong.
Does it compile?
Runtime error?
or what

T~M

blulightning

2009-06-26 20:10:38

Right, sorry, it doesn't compile at all, and I can't seem to figure out the error. It doesn't show in the text box beneath the script, it only says, 'Failure to Compile'

Macro_FTW

2009-06-26 20:16:08

Error:
Failed when compiling
Line 69: [Error] (19086:1): Unknown identifier 'AntiRandoms' in script

You need an AntiRandoms procedure. Here's mine if you want to use it; just make sure to credit me if you use it, please. :)


It's the one I use in all of my scripts, and works pretty well. ;)

function AntiRandoms: Boolean;
begin
Result := False;
if FindFight then
begin
RunAway('n', True, 1, 2000);
Result := True;
end else
Result := FindLamp(***LAMP_SKILL_HERE***) or FindNormalRandoms;
end;

~Macro_FTW

Dynamite

2009-06-26 20:18:42

what macro said.
you cant call for a procedure that doesnt exist.
add my msn and i will help you some more
[email]destiful@hotmail.com[/email]

T~M

Coh3n

2009-06-26 20:47:51

Could you please put your code in SCAR tags, instead of QUOTE tags. It makes it a lot easier for us to read. If you don't know what I mean replace the QUOTE part with SCAR, and it will work.

Thanks.

Dynamite

2009-06-26 20:55:58

no point in:
wait(2453+Random(432));
just do
Wait(2500+Random(500));
i mean there isn't anything wrong with yours but there no point ;)

T~M

blulightning

2009-06-26 20:57:52

Thanks everyone!! I will test out the new stuff and let you know how it works.

EDIT: @The Man i picked those number because i figured that the more random the numbers, the less uniform the script would be in that it wouldnt act exactly like other bots

ian.

2009-06-26 20:58:15

Or


Wait(RandomRange(2500, 3000));

>.> Only did that because you're getting so picky about it.

Dynamite

2009-06-26 20:59:36

OR that ^^ :p
I was just explaining to him that he doesn't need to have random numbers like 2436 because it will add randomized on it anyway :p

T~M

blulightning

2009-06-26 21:08:02

Wait, so it doesn't make it any better to use random numbers? Okay, I'll change it to neaten it up.

Dynamite

2009-06-26 21:09:36

No it doesn't
just have:
Wait(2500+(Random(500)));
OR
Wait(RandomRange(2500,3000));
Hope this helps.

T~M

blulightning

2009-06-26 21:11:41

yep, I fixed it now, thanks a ton!!

ian.

2009-06-26 21:17:16

Fix'd.


program New;
{.include srl/srl.scar}

Procedure NamePlayers;
begin
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';{Added this for randoms :)}
Players[0].Active := True;
end;
{You had procedure AntiRandoms here, and you needed to take it out.}
function AntiRandoms: Boolean;
begin
Result := False;
if FindFight then
begin
RunAway('n', True, 1, 2000);
Result := True;
end else {You have to choose the skill, so I did woodcutting, as it's a woodcutting script ;]}
Result := FindLamp('woodcutting') or FindNormalRandoms;
end;

procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
FindNormalRandoms;
case Random(8) of
0:
begin
HoverSkill('Woodcutting', false);
Wait(2500+Random(500));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
FindNormalRandoms;
end;
end;
end;

procedure ChopTree;
var x, y: integer;
begin
repeat
FindNormalRandoms;
if FindObj(x, y, 'hop', 2584417, 40) then
Mouse(x, y, 0, 0, false);
ChooseOption('hop');
repeat
wait(400+random(250));
AntiBan;
Until not IsUpText('ree') or (InvFull);
until(InvFull);
end;

procedure RandomDrop(StartSlot, EndSlot : Integer); //Random Drop : Drops inventory in completly random order
var i,s,c : Integer;
AlreadyDropped : Array of Integer;
begin
SetArrayLength(AlreadyDropped, (EndSlot-StartSlot) + 1);
for c:= 0 to High(AlreadyDropped) - 1 do AlreadyDropped[c]:= 0;
repeat
i:= Random((EndSlot-StartSlot) + 1);
if (AlreadyDropped[i] = 0) then
begin
case Random(28) of
0..26: DropItem(AlreadyDropped[i]);
27: begin
MouseItem(AlreadyDropped[i],false);
ChooseOption('xamine');
Wait(100 + Random(200));
DropItem(AlreadyDropped[i]);
end;
end;
AntiRandoms;
AlreadyDropped[i]:= 1;
Inc(s);
Wait(200 + Random(200));
end else
begin
end;
until(s = EndSlot-StartSlot + 1);
end;

begin
SetUpSRL;
ActivateClient;
NamePlayers;
ChopTree;
RandomDrop(1, 28);//You had to add the (1, 28) after RandomDrop :)
end.

blulightning

2009-06-26 21:19:32

Thanks 99!!! The comments helped a lot. I'll let you guys know how it runs, im going to use it right now.

EDIT: this could be entirely unrelated, but whenever i try to run the script, Math.scar opens itself and displays this error:
Line 46: [Error] (268:11): Unknown identifier 'CreateTPAFromBMP' in script C:\Program Files (x86)\SCAR 3.20\includes\SRL/SRL/Core/Math.scar

Macro_FTW

2009-06-26 21:35:52

Move your plugins. :P

EDIT:
Random numbers are generated so that it looks less uniform. Using wait(2435+Random(234)) is no different than wait(2500+Random(500)), except for the fact that it may be around .06 seconds faster. Random(x) adds a random number from 0 to x-1 on to the end, so they essentially are the same randomness. ;)

Also, as stated, RandomRange is an awesome tool. It makes wait(RandomRange(2500, 3000)) more readable than wait(2500+random(500)) and makes changing the range a tiny bit easier. ;)

~Macro_FTW

ian.

2009-06-26 21:37:22

Ninja'd.

blulightning

2009-06-26 22:59:33

Okay. I think i have mostly everything under control now, except this one thing. Hopefuly this will be my last question.
When I run the script, I target the window, and I put my user, pass, and nick into it. I've got all of that right. However, I get this error:

[Runtime Error] : Out Of Range in line 6 in script C:\Program Files (x86)\SCAR 3.20\Scripts\First Script-Chopper.scar

Coh3n

2009-06-28 22:56:26

From: blulightning
Okay. I think i have mostly everything under control now, except this one thing. Hopefuly this will be my last question.
When I run the script, I target the window, and I put my user, pass, and nick into it. I've got all of that right. However, I get this error:

[Runtime Error] : Out Of Range in line 6 in script C:\Program Files (x86)\SCAR 3.20\Scripts\First Script-Chopper.scar


Add this to your DeclarePlayers:


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