
Originally Posted by
shuttleu
well this is my first script which i have written entirely from scratch
and what do you mean by
there isn't even anything underneath
~shut
Yes, yes, my appologies, I forgot to edit the post and give feedback, let's begin, shall we?
SCAR Code:
function AutoFurnaceSymb: Integer;
Is made with ACA v.2.
SCAR Code:
function AutoBankSymb: Integer;
Is made with ACA v.2.
SCAR Code:
function FindObjCustom1(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tolerance: Integer): Boolean;
A function from the SRL folder.
SCAR Code:
function ShopScren : Boolean;
Tip:
Make a new variable, an integer, and load the shop ddtm in that variable.
*You don't load the shop ddtm, if this fucntion is being called multiple times (which happens), SCAR will have a big memory leak and your script will stop functioning.
*Do the above (the tip)and after usage of the ddtm (thus at the end of your funciton), free it.
I want you to have a look at this:
SCAR Code:
repeat
FindNormalRandoms;
FindObjCustom1(x, y, ['ank', 'oot'], [737364, 670799], 30)
Writeln('found bank');
MMouse(x, y, 1, 1);
Wait(500 +random(500));
Mouse(x, y ,1, 1, false);
ChooseOption('ickly');
Wait(2000 +random(1000));
until Bankscreen or Pinscreen;
First of all, it'll check for randoms, secondly it'll try to find the bank booth and here it get's wrong..
Even if the bank booth hasn't been found, it'll still output that the bank is found and do the mouse actions.
Let's think about it: the bank booth isn't found, the funciton will:
*output a message in the SCAR Debug Box that the bank booth has been found
*Move the mouse and click the mouse at x, y coordinates, which are the coordinates from an object found in a previous procedure/function (you use x and y in other object finding procedure's/functions aswell, so the x and y will hold the coordinates found of the previous object finding..).
This will have a result of: weird mouse movements, which isn't humanly at all (it'll also right click, which makes it more detectable).
The even bigger problem that I see in that procedure, is that you have an infinite loop
SCAR Code:
until Bankscreen or Pinscreen;
What do you have to do to avoid this?
Add a variable and increase it every time you try to find the bankbooth and repeat that all until the bank/pin screen is popped-up or when your maximum tries has been reached (then put player false, etc..).
You can use other methods like using a timer
Further in the procedure:
SCAR Code:
if Players[currentplayer].strings[0]= 'soft' then
begin
Withdraw(1, 1, 27);
end;
if Players[currentplayer].strings[0]= 'hard' then
begin
Withdraw(1, 1, 81);
end;
*plz make a case statement for this
*why don't you load your ddtms for withdrawing, then you're sure that you've withdrawed the correct objectives
SCAR Code:
if not(FindDTM(WhichDDTM('hide'), x, y, MSX1, MSY1, MSX2, MSY2)) then
begin
CloseBank;
Error('withdrawing cowhides', 'No cowhides left in the bank');
NextPlayer(false);
end;
if FindDTM(WhichDDTM('hide') ,x, y, MSX1, MSY1, MSX2, MSY2) then
begin
repeat
MMouse(x, y, 1, 1);
Wait(500 +random(500));
Mouse(x, y, 2, 2, false);
Wait(500 +random(500));
ChooseOption('Withdraw All');
Wait(1000 +random(1000));
until FindDTM(WhichDDTM('hide'), x, y, MIX1, MIY1, MIX2, MIY2);
end;
*To begin with, make from this a "if-then-begin-end-else-begin-end" statement instead of just "if-then-begin-end" 2 times
*Againt, load your ddtm in a variable and don't forget to free it, because you didn't free'd it over here aswell
*I see that you don't understand the "RadialWalk" function properly.
SCAR Code:
function RadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;
You use it like this:
SCAR Code:
if RadialWalk(cactuscol , 10, 100, 70, x, y) then
*you have a range of 90 between your begin- and endradial, try to use a max range of 70 (optional)
*you have 70 radius, that the very end of your minimap, be sure you wont have trouble
*This doesn't mean the x and y coordinate.. it's a randomize number, you can compare it with the randomazation of MMouse --> MMouse(fx, fy, 1, 1).
However, try to use "RadiaWalkEx", where you can use a tolerance etc
NOTE: RadialWalkEx doesn't already clicks, you'll need to move your mouse and click when using that
Tip: Make function from this, which returns a boolean, so that you can see if you've walked to the tanner succesfully.
Same comments as "WalkToTanner".
SCAR Code:
if Players[currentplayer].strings[0] = 'soft' then
begin
ReportVars[1] := ReportVars[1] + CountItemsDtm('inv', WhichDDTM('soft'));
end;
if Players[currentplayer].strings[0] = 'hard' then
begin
ReportVars[2] := ReportVars[2] + CountItemsDtm('inv', WhichDDTM('hard'));
end;
*Put this in a case statement
*Again, load your ddtm's in a var and free them after usage
*ReportVars glitch, you'll update your stats, while you don't know if you've reached the bank or not
Again some problems like in other object finding procedures (like banking).
*
SCAR Code:
if FindObjCustom1(x, y, ['alk', 'llis'], [4944848, 4680900], 30) then
> problem already stated somewere else above: make it an if statement, infinite loop problem, etc..
Your mainloop:
Your mainloop isn't set up properly, check some tut, if I've got to explain this I'm not done by tomorow
Generally notes:
* I see you could've declared some variables local instead of global, do so,
it improves script run.
* Have more failsafes, those are really needed. The best script around have many failsafes,
so that better script run is guaranteed!
Generally hint:
* If there occurs a problem, log out your player andexit out of the current procedure/function.
* Put at every procedure and function "if not(LoggedIn) then Exit;"
* In your mainloop, when you switch players (which should be the only place were you switch players) use "NextPlayer(LoggedIn);"
Why should I do this? What does this do?
Well, if this is used correctly, you do the following:
There occurs a problem, your player gets logout and you exit out of the current procedure/function.
It wont do another procedure or function because you're logged out and you have "if not(LoggedIn) then Exit;' at the very beginning of every procedure/function.
You'll get to the end of your repeat and your script will do "Nextplayer(LoggedIn)", you're not logged in, so you'll put the current player's status to falseand go on with the next one
Conclusion:
I think you've put a lot of work into this, but we have to see the facts, my friend.
The better things aren't made by you, the things you made by yourself need some fixing and you make a lot of "beginner" mistakes such as inproperly use of if-statements and no (d)dtm free'ing.
Still nice work dude
I hope to see more of you in future, keep it up!
-Tsn.
P.S. the things mentioned above are ment to be contructive criticism, don't blame me or this will be the last time I give you feedback.