From: Er1k
SortTPAFrom returns the sorted TPointArray, closest to your position first. Array[0] is the answer to your question
Yep pretty much.
First, we define our own player's position on the MM (Me := SPS_GetMyPos), this will be a TPoint. Next, we use the nifty little procedure "SortTPAFrom" which has 2 parameters: the first is the given TPointArray. Two steps are done here, first you feed your TPA into the procedure and in that same parameter your TPA will be given back to you, but in a sorted (by distance) form. The second parameter is the point you want to start the sorting
from. In this case we use our player's location (Me).
At this point, our TPointArray has been sorted by distance from our player. And as you know, every array starts at 0, with 0 being the first in the array. So… PArr[0]
must be the closest point to our player because its first on our sorted array. The second closest point would be PArr[1], third would be PArr[2], ect… You get the idea. ;)