I apologize for the delay. I wanted to make sure I'd have enough time to come up with an educational post beneficial to as many people as possible.
First, I'd like to talk a bit about theories and why TPA are so highly regarded. I recall that, not so long ago, TPA were, to me, some kind of mythical creature with an aura of mystery. For this reason, I find it important to stress what TPA stands for: TPointArray or, if you prefer, an array of TPoints. As you might know already, a TPoint is a set of two coordinates (x, y) giving you a point. The usefulness of TPA is that it gives you multiple points on the screen, therefore giving you a chance to find what you're looking for in case you mess up the first time. This is why adding a loop to go through each points is that important. It's also important to add some kind of failsafe to make sure you're getting what you want. On the official runescape server, this can easily be done by using UpText, but it's a bit more complicated for private servers. I leave that part to you though.
Being a lazy person, I'll just paste the basic TPA finding function that I use. Many things can be edited to narrow down the search, but I'd rather keep it simple as this is meant as just one helpful post and not a tutorial.
Here it is:
function FindObject(var x, y : Integer; Obj: MSObject; X1, Y1, X2, Y2:integer) : Boolean;
var
a : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box : TBox;
begin
if not LoggedIn then Exit;
tmpCTS := GetColorToleranceSpeed; //Saves your setting not to mess up your whole colour finding for the rest of the script.
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Obj.Hue, Obj.Sat);//Sets the hue and sat of the item.
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Obj.Col, X1, Y1, X2, Y2, Obj.Tol); //Self explaining I hope.
SortTPAFrom(TPA, point(MSCX,MSCY)); //Starts the list of TPA from the center. Aka the TPA[0] will be the one closer to the center. Can be changed based on our needs.
ATPA := TPAtoATPAEx(TPA, 15, 15); //One of many possible function used to reduce the length of the array and have more precision. Read TPA tutorials to learn more about those as they don't all do the same, but that one groups some TPA into ATPA.
for a := 0 to High(ATPA) do //Since I transformed my TPA into an ATPA, I loop through those. If you decide to stick to TPA, the loop would be different. For example, using rjj95's function, it'd be "for a := 0 to high(FishSpotTPA) do"
begin
MP := MiddleTPA(ATPA[a]); //Checks the middle of the TPA.
MMouse(MP.x,MP.y,4,4); //EDIT: Had accidentally removed this line in the editing
if(WaitUpText(Obj.UpText, 400))then //UpText failsafe. Could be changed to anything though to ensure that you got the TP you want.
begin
x := MP.x; y := MP.y; //Just the way the function is built. It gives the var x and y at this point.
Result := True //Hope I don't need to explain.
Break; //You obviously want to get out of the loop once you found what you want. Do not exit though.
end;
end;
ColorToleranceSpeed(tmpCTS); //Goes back to the earlier settings. Try not to skip those lines.
SetColorSpeed2Modifiers(0.2,0.2);
end;
Note: MSObject is a record with a lot of information. If you don't fully understand that part, don't worry. Focus on the actual content of the function.
If anything is unclear, feel free to ask for more information.