Best way to get three/four/five closest positions from an array? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Best way to get three/four/five closest positions from an array? (
/showthread.php?tid=646652)
Best way to get three/four/five closest positions from an array? -
Puppy - 21.12.2017
Working on a system that involves getting the three or so closest object positions from quite a large array, in comparison to a specific player. Keep in mind they not only have to be closest, but fit within a general range in categorization.
So:
- Last object/position set: somewhere around 8000 - 10000 meters from player.
- Third object: somewhere around 6000 - 8000 meters from player.
- Second object: somewhere around 4000 - 6000 meters from player.
- First object: anything BELOW 4000.
Any ideas on the most
efficient way to accomplish this? I've thought of a few ways to do this, but I'm sure they're not the best methods. Thoughts?