Log in

View Full Version : need help with first script



hopetobedabest
10-17-2010, 03:47 AM
i am working on my frist script its a willow cutter and banker adn hear it is

program DraynorWillowCutterBanker;
{.Include SRL\SRL\Misc\SMART.SCAR}
{.Include SRL\SRL.SCAR}
{.include SRL/SRL/Skill/WoodCutting.scar}

var
x,y:Integer;

const
bankpin:= 0000;
walktotree:= 33814009;
walktobank:= 12632256;

procedure declareplayers;
begin
howmanyplayers:=1;
numberofplayers(howmanyplayers);
players[0].name:='username';
players[0].pass:='pass';
players[0].nick:='3- for letter of your name';
players[0].active:=true;
Mousespeed:= 20;
end;
procedure PreparePlayer;
begin
if not LoggedIn then LoginPlayer;
SetRun(True);
end;

procedure randoms;
begin findnormalrandoms;
if findfight=true then
begin runaway('E',true,1,5000+random(1000));
end;
end;
procedure AntiBan;
begin
if not LoggedIn then Exit;
case (Random(30)) of
11: RandomMovement;
15: BoredHuman;
24: PickUpMouse;
27: begin
Gametab(1 + Random(12));
Wait(3220 + Random(2415));
Gametab(4);
end;
30: SleepAndMoveMouse(3600);
end;
end;
Procedure ChopTree;
begin
if not LoggedIn then
Exit;
repeat
if FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7) then
begin
Mouse(x,y,0,0,false);
repeat
Wait(100 + (random(150)));
ChooseOption('hop')
until(InvFull)
end;
until(InvFull)
end;
function Banking: Boolean;
begin if (InvFull) then
begin
MakeCompass('N')
Wait (300 + random(160));
OpenBankQuiet('db');
if (PinScreen) then
InPin(YourPin);
if(FindColorSpiral(x, y, 4155248, 547, 206, 734, 464))then
begin
Mouse(x, y, 4, 3, false);
ChooseOption('All'); end;
CloseBank;
Wait(150 + random (278));
end;
end;



begin
end.

i need some feed back on how im dong to far bc i dont want to conintue if some thing is wrong and i need some help with map walking
to acctully get the the trees and to get to the trees to the bank plz help :)

RISK
10-17-2010, 12:11 PM
You need to work on your standards. Try to get in to the habit of proper standards right away, it's better than trying to break sloppy standards habits later. Here is a thread about standards: HERE (http://villavu.com/forum/showpost.php?p=618673&postcount=2) (Scroll down to "Standards") or HERE (http://villavu.com/forum/showthread.php?t=3293).

Your DeclarePlayers Procedure:

procedure declareplayers;
begin
howmanyplayers:=1;
numberofplayers(howmanyplayers);
players[0].name:='username';
players[0].pass:='pass';
players[0].nick:='3- for letter of your name';
players[0].active:=true;
Mousespeed:= 20;
end;


This should be:


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

with Players[0] do
begin
Name := ''; // Character username
Pass := ''; // Character password
Nick := ''; // Character nickname (3 ~ 4 letters of username)
Pin := ''; // Character bank pin
Active := True;
MouseSpeed := 9 + Random(3)); // 9 ~ 12 mouse speed (Random, of course)
end;
end;


You had your MouseSpeed up to 20 which is WAY too much in my opinion. I mean, wow. Try playing around with the mouse speed and make it click around your desktop or something with different mouse speeds each time. It will help you learn how fast each speed is and such.


Your Randoms Procedure

procedure randoms;
begin findnormalrandoms;
if findfight=true then
begin runaway('E',true,1,5000+random(1000));
end;
end;


You should not have a procedure for finding randoms. It should be all around your script in certain spots.

Why do you have that FindFight check? There are no randoms that are hostile anymore.

You should also not do:

begin runaway('E',true,1,5000+random(1000));
end;


Instead you should have done:

begin
RunAway('E', True, 1, 5000, Random(1000));
end;


But that's just more standards stuff.


Your PreparePlayer Procedure
This could be removed and just added in to a MainLoop procedure at the bottom of the script. That is where you would set everything up.


Your Antiban Procedure
Antiban shouldn't be in a whole different procedure, for one. You should also increase the 30 to be a MUCH higher number. The way the random number picking works is that it picks tons of numbers each second. (I may be exaggerating. Bare with me, please.) So you need to have a much higher number for an antiban to be somewhat succesful.


Walking:
See THIS (http://villavu.com/forum/showthread.php?t=19162) thread Cohen's (http://www.villavu.com/forum/showpost.php?p=618674&postcount=3) (Scroll down to walking) or check out a few of these: TRiLeZ (http://www.villavu.com/forum/showpost.php?p=673398&postcount=5) (Scroll down to walking) or just search around in the Intermediate scripting tutorials section HERE (http://villavu.com/forum/forumdisplay.php?f=96)!


If you need anymore help, feel free to ask.

hopetobedabest
10-17-2010, 09:50 PM
this is exactly what i need thanks mm so basicly i need to work on my "neetness" alot and as for the prosedures once i make them i can just put them in the order i want them to used and it will work? im still grasping on how to acctully write the part of the script that acctully usses the cammands that u write and as for the the anti ban and anti random stuff i could use some more help at that if u could thanks for the help

RISK
10-17-2010, 09:59 PM
Yes. You do need to work on your standards (Neatness and readability).

For the procedures it will work in the position you put them in. (If I understood your question correctly). So basically if you have this:

procedure Position1;
begin
Command01;
Command02;
Command03;
end;


It will go from 01 -> 03 in the order that you put them in. But if you have this:

procedure Position2;
begin
Command03;
Command01;
Command02;
end;


It will go from 03 -> 01 -> 02 in that order.

Well what do you need help on with AntiBan and AntiRandoms, exactly? I made this for you so that you could see an option in AntiBan and AntiRandoms, if that is what you needed help in:


procedure ChopTree;
begin
// TreeChopping stuff here -
repeat
case Random(502) of
0 .. 23 : AntiBanStuff;
66 .. 101 : MoreAntiBanStuff;
end;
FindNormalRandoms;
until not (IsUpText('hop')) or (InvFull);
end;


That is a very rough example, but it should help you get the point of it.

If you need anymore help, feel free to ask.


this is exactly what i need thanks mm so basicly i need to work on my "neetness" alot and as for the prosedures once i make them i can just put them in the order i want them to used and it will work? im still grasping on how to acctully write the part of the script that acctully usses the cammands that u write and as for the the anti ban and anti random stuff i could use some more help at that if u could thanks for the help

hopetobedabest
10-17-2010, 10:06 PM
so i would write the anti ban anti random stuff in the main procedure that i will be using sence i all ready have them written out cant i just write the procedures in the tree chop prosedure?

im looking at the radial walking right now

RISK
10-17-2010, 10:10 PM
I would suggest you take your time on radial walking and learn Symbol clicking too. They are very useful and you will be using them frequently in your scripting.

Yes, you should write the AntiBan / AntiRandom stuff in the "Main" procedure that you will be using to chop trees.

I could write a quick tree chopping procedure and add the AntiBan / AntiRandoms in to it, if you would like to learn from that instead.


so i would write the anti ban anti random stuff in the main procedure that i will be using sence i all ready have them written out cant i just write the procedures in the tree chop prosedure?

im looking at the radial walking right now

hopetobedabest
10-17-2010, 10:14 PM
could u ? that would be a help

i gess im puting every thing into prosedures lol and just using thos thats what it looks like and i have a feeling your going to tell me y that would not work well lol

and can u explain main loops plz

hopetobedabest
10-17-2010, 10:42 PM
i am geting this error Line 71: [Error] (21484:15): Type mismatch in script C:\Program Files\SCAR 3.22\Scripts\willowcutter.scar

can i have this now RadialRoadWalk({TheColor}, 295, 340, 47, -1, -1);

how do i use the auto color for (thecolor)?

RISK
10-17-2010, 10:44 PM
What is your current code? (Around line 71, please).

I would suggest you wait and not use AutoColoring until later. Simply get the color from the minimap with the color picking tool and use that for {TheColor}.


i am geting this error Line 71: [Error] (21484:15): Type mismatch in script C:\Program Files\SCAR 3.22\Scripts\willowcutter.scar

Here is a main loop example:


procedure MainLoop;
var Runs : Integer;
begin
SetupSRL;
ActivateClient; // This does not need to be used if you are using SMART
DeclarePlayers;

if not LoggedIn then
begin
WriteLn('We are not currently logged in! Logging in now..');
LogInPlayer;
Wait(1000);
WriteLn('We are now logged in! Starting the script..');
end;
repeat
Runs := Runs + 1;
// Script stuff here like this:
ChopTrees;
WalkToBank;
UseBank;
WalkToTrees;
until(Runs >= 1); // Change "1" accordingly!
end;


I'll have the tree chopping procedure done in a few moments.

hopetobedabest
10-17-2010, 10:56 PM
would i just put = false at end of loop to make it coninue for ever and i thought the color changes ecvery 5 min so dont i kinda have to use autocolor?

and im testing my radial

program test;
{.Include SRL\SRL.SCAR}
{.include SRL/SRL/Skill/WoodCutting.scar}
begin
function RadialWalk(3511970, 295, 340, 47, -1, -1)Boolean;
end.

and i get this error Line 5: [Error] (21289:1): Identifier expected in script
probaly some thing really stupid

really thank for all the help and im still sketchy what should i make a prosedure and what should i just put in the main sript

RISK
10-17-2010, 11:13 PM
Tree chopping procedure (Very rough, bare with me, please):


program AntibanAndAntiRandoms; //
{$i SRL/SRL.scar}

var X, Y : Integer;

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

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active:=True;
end;
end;

procedure ChopWillows;
var Chopped, Tries : Integer;
begin
if not LoggedIn then Exit;
FindNormalRandoms;

if FindObjCustom(X, Y, ['hop', 'il', 'lo'], [3168098, 5670004, 4219987, 4813151], 16) then
begin
Mouse(X, Y, 5 + Random (3), 6 + Random (4), False);
ChooseOptionMulti(['hop', 'il', 'lo']);
WriteLn('We are chopping a willow tree!');
FindNormalRandoms;
repeat
case Random(707) of
0 : MakeCompass('N');
1 : MakeCompass('S');
2 : MakeCompass('W');
3 : MakeCompass('E');
73..100 : BoredHuman;
311..340 : PickUpMouse;
end;
until not(IsUpTextMultiCustom(['hop', 'il', 'lo'])) or (InvFull);
WriteLn('The tree is not there anymore!');
FindNormalRandoms;
Exit;
end else
end;

begin
SetupSRL;
DeclarePlayers;
ActivateClient;
ChopWillows;
end.


Remove the "Function" and the "Boolean" segments of "function RadialWalk(3511970, 295, 340, 47, -1, -1)Boolean;". Those are unneeded.

You would put this:

procedure NameHere;
begin
repeat
StuffHere;
until(False);
end;


For an infinite loop. These are HIGHLY not recommended though! They can cause problems later on for your script!

The main procedure is where everything loops. A main loop. You would put what is needed in a procedure. Like one for walking to the bank, walking to the trees and etc.

hopetobedabest
10-17-2010, 11:21 PM
whats the setupsrl and where does it come from and
ok the test script compiled but how do i make it actually walk now

RISK
10-17-2010, 11:24 PM
"SetupSRL" sets the script up after you use "{.include SRL/SRL.scar}"/"{$i SRL/SRL.scar}. It is needed for actually using the SRL functions and procedures.

You need to make new procedures for each thing you want to do, like this:


procedure WalkToTrees;
begin
// Radial walking
end;

procedure UseBank;
begin
// UseBank functions and such
end;

procedure WalkToBank;
begin
// Radial walking
end;



whats the setupsrl and where does it come from and
ok the test script compiled but how do i make it actually walk now

hopetobedabest
10-17-2010, 11:29 PM
i have this program test;
{.Include SRL\SRL.SCAR}
{.include SRL/SRL/Skill/WoodCutting.scar}
begin
setupsrl
RadialWalk(3511970, 295, 340, 47, -1, -1);
end.

when i run it compiles but does not walk

and i dont fully get declare players

RISK
10-17-2010, 11:32 PM
You forgot to use "ActivateClient;" after you set SRL up.

What exactly do you not get about DeclarePlayers? I can explain as best as I can if you give a little more details on what you do not understand.


i have this program test;
{.Include SRL\SRL.SCAR}
{.include SRL/SRL/Skill/WoodCutting.scar}
begin
setupsrl
RadialWalk(3511970, 295, 340, 47, -1, -1);
end.

when i run it compiles but does not walk


and i dont fully get declare players

hopetobedabest
10-17-2010, 11:44 PM
must of just made bad dimintions only made falg 1 out of 9 times and it was not even right like i said before dont u need autocolor bc color changes

idk i dont really need declarplayers so i just wont use it

RISK
10-17-2010, 11:46 PM
Yes, you do need DeclarePlayers. It is for character information for randoms and such. You cannot avoid using it.

You do not need AutoColor in this case. Just use symbol clicking to get to the bank if you are chopping near Draynor bank. Then for walking back to the trees, simply use more symbol clicking to click the fishing spot next to the willow trees.


must of just made bad dimintions only made falg 1 out of 9 times and it was not even right like i said before dont u need autocolor bc color changes

idk i dont really need declarplayers so i just wont use it

hopetobedabest
10-17-2010, 11:50 PM
ok i will look more into symbols is there any thing u think i need to know for this willow cutter at draynor?

RISK
10-17-2010, 11:52 PM
You need to know the following:
Banking
Tree finding and chopping
Symbol clicking
DeclarePlayers and logging in the player
Antiban
Antirandoms


ok i will look more into symbols is there any thing u think i need to know for this willow cutter at draynor?

hopetobedabest
10-18-2010, 12:01 AM
or could i use bitmaps as the symbols?

RISK
10-18-2010, 12:02 AM
That would be inefficient and slow. I do not suggest it. But you could try anyway.


or could i use bitmaps as the symbols?

hopetobedabest
10-18-2010, 12:04 AM
ok what are bitmaps used for then?

RISK
10-18-2010, 12:09 AM
Multiple things. There are better alternatives though, it just depends on what you would want to use them for.


if FindSymbol(X, Y, 'bank') then
begin
Mouse(X, Y, 3, 4, True);
Flag;
end;


Symbol finding and clicking example. It should be self explanatory. If you have any questions, feel free to ask them.


ok what are bitmaps used for then?

hopetobedabest
10-18-2010, 12:18 AM
u think i can actully make this script now

tree fining like once im were trees are check area for symbol if true than chop if not look again

RISK
10-18-2010, 12:25 AM
Yes, you are fully capable of creating a script. But you need to work on the things that I suggested and such. You will also learn new things while you go along and make even more scripts.

Reask your question better, please. @ Second half


u think i can actully make this script now

tree fining like once im were trees are check area for symbol if true than chop if not look again

hopetobedabest
10-18-2010, 12:32 AM
like u said i would have to know tree finding so say im all rady at the trees would i find them by like searching the screen some how and if symbol is not found than search tell it is found if found chop

hopetobedabest
10-18-2010, 12:35 AM
and how would i deal with axe breaking and what not

and is normalrandom a built in function so it just deals with all the randoms for u?

i luffs yeww
10-18-2010, 12:47 AM
Axes don't break anymore.

FindNormalRandoms will deal with randoms, you just have to use it effectively (at the right places and what not).

hopetobedabest
10-18-2010, 12:49 AM
wow so much has changed lol


ok can u just explain declareplayers as a hole y use it what does it do and y use it

RISK
10-18-2010, 01:00 PM
I'm sorry for the late reply to your question.


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

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active:=True;
end;
end;


What "DeclarePlayers" is:
DeclarePlayers is for character information that is used to log in to the game and detecting. This is a very needed procedure. All you have to do is "Call" on it in your main loop procedure and then you are set!

What "DeclarePlayers" is used for:
Logging in your character and random detection.

--

"with Players[0] do":
This is a neater and more "Advanced" way to say this:

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Pin := '';
Players[0].Active:=True;


Name: Character username
Pass: Character password
Nick: Character nickname (3 ~ 4 letters of the username)
Pin: Character bank pin
Active:=True: This tells your script that this character / player is active and is to be used in the script.


Here is a script that uses DeclarePlayers and MainLoop procedures. It is a very rough example of what could be done with a MainLoop procedure. It should be self explanatory though.


program new;
{$i SRL/SRL.scar}

var X, Y : Integer;

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

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active:=True;
end;
end;

procedure MainLoop;
begin
SetupSRL;
DeclarePlayers;
ActivateClient;
LogInPlayer;
ClearDebug;
if InvFull then
begin
WalkToBank;
UseBank;
WalkToTrees;
end else
repeat
ChopTrees;
WalkToBank;
UseBank;
WalkToTrees;
until(Runs >= 1);
end;

begin
MainLoop;
end.



wow so much has changed lol


ok can u just explain declareplayers as a hole y use it what does it do and y use it

If you need anymore help, feel free to ask.