Log in

View Full Version : Private server autofighter



Dub
08-12-2012, 08:59 AM
Alright so I'm writing this PS autofighter, pretty much completely writing it myself because 99% of the SRL functions do not work on those anymore. Everything goes well until I suddenly get an error in a function that didn't create any errors before... without changing anything to the actual function...

Exception: Range check error at line 54

The function that returns this range check error is:


Function LowHealthz : Boolean;
begin

if FindColor(hpx,hpy,2070783,724,24,751,41)
then Result:=True
else Result:=False;

end;

P.S. I made the hpx and hpy LongInt variables just to be sure that they can contain the coords returned (yes, I was that desperate)

This function basically checks for the orange color of medium health in the small hp box next to your HP orb in the top right corner. Now, I read that it might be due to the fact that the coords I filled in at the FindColor are out of my client range, but I used the colorpicker to check and they're not. I tried rewriting but it keeps returning the same error to me.

Also, when this error occurs (= every time now..) it instantly closes the client window I have selected (which is a custom private server .jar that works fine with other scripts I wrote so far).

Any ideas or suggestions as to how to fix this? Would be much appreciated :)

riwu
08-12-2012, 09:03 AM
You can just do
result:= FindColor(hpx,hpy,2070783,724,24,751,41);

The y-coordinates are 50 off if you called SetupSRL.
Refer to http://villavu.com/forum/showthread.php?t=87720 for more info

Dub
08-12-2012, 10:47 AM
I did not call SetupSRL; When I deduce 50 from the y coordinates in my function, they turn into negative numbers. I then get Simba telling me that's an invalid ys value. Simba has a point. Any other tips?

Edit: I just restarted pc. Started client then pc. The script started "running" and the client did not crash. But the script never made any mouse movements. It just sat there. Then when i stopped and ran it again, it gave me the Range check error at line 51 which is:


Function LowHealthz : Boolean;
begin

result:= FindColor(hpx,hpy,2070783,725,25,750,40);

end;


What the heck am I doing wrong?

riwu
08-12-2012, 10:56 AM
I did not call SetupSRL; When I deduce 50 from the y coordinates in my function, they turn into negative numbers. I then get Simba telling me that's an invalid ys value. Simba has a point. Any other tips?

Edit: I just restarted pc. Started client then pc. The script started "running" and the client did not crash. But the script never made any mouse movements. It just sat there. Then when i stopped and ran it again, it gave me the Range check error at line 51 which is:


Function LowHealthz : Boolean;
begin

result:= FindColor(hpx,hpy,2070783,725,25,750,40);

end;


What the heck am I doing wrong?
Can u post the whole debug and the script? Also the mouse will move very slowly if you didn't set MouseSpeed.

Dub
08-12-2012, 12:27 PM
Alright. I switched from the downloadable client to the webclient, now included SetupSRL in my loop and adjusted all the coordinates. It now runs nicely.

I have another question. I made several booleans to return certain things like if the character is low on hp, low on prayer, if the player is out of combat etc.

These work nicely. Now, I want to have a procedure where it logs out if the following conditions are ALL met:

Character is out of combat.
Character has low health.
Character has low prayer.

What would be a good way to trigger my logging out procedure if all three booleans are true?

tl;dr:
How do I make a procedure check multiple variables before commencing action, and otherwise doing nothing?

riwu
08-12-2012, 12:46 PM
if (out_of_combat and low_health and low_prayer) then
LogOut;

Dub
08-12-2012, 12:58 PM
So in theory this would work:

begin
if (not(InDaFight) and LowHealthz and VeryLowPrayz) then
LogOut;
end;

riwu
08-12-2012, 01:03 PM
So in theory this would work:

begin
if (not(InDaFight) and LowHealthz and VeryLowPrayz) then
LogOut;
end;
Yeah. It will only check for these conditions when you call it, so u'll have to call it in every procedure/loop where you want it to check.
Also may have to write ur own LogOut procedure since it's private server.

Dub
08-12-2012, 10:13 PM
Yeah I'm used to writing everything myself. SRL isn't of much use to be honest :P. It turned out great, thanks for the help when I really didn't see the trees through the forest :).