pls help me: GetClosestPlayers - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: pls help me: GetClosestPlayers (
/showthread.php?tid=141586)
pls help me: GetClosestPlayers -
DJ-CJ89 - 14.04.2010
Hello everybody. ill make it short. I want to script a textdrawlist. I just want to know how i can get the 2nd,3rd,4th etc.. nearest Player from another Player. I know how to get the first nearest Player. With GetClosestPlayer. But how i can get the others? With an exception? Pls write an example. Thanks for your help

.
1. Nearest Player
2. 2nd Nearest Player (how to find out this?)
3. 3rd Nearest Player (and this?)
etc.
CJ89
Re: pls help me: GetClosestPlayers -
RichyB - 14.04.2010
Could have it so it gets the ClosestPlayer for the number 1 person then nearest person to number 2.
Re: pls help me: GetClosestPlayers -
DJ-CJ89 - 14.04.2010
nah that wont work correctly because it would return the same player sometimes and i also get incorrect results. Are there no other ways or is there another code to find that out?
Re: pls help me: GetClosestPlayers -
VirSpectorX - 14.04.2010
Try using IsPlayerInRangeOfPoint but make it in a loop.
I mean using for, such as:
pawn Код:
new string[125];
new Float:x;
new Float:y;
new Float:z;
SendClientMessage(playerid, #COLOR#, "Closest player (arranged from the nearest)");
for(new i=1; i < 11; i++)
{
for(new a = 0; a < MAX_PLAYERS; a++)
{
GetPlayerPos(a, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, i, x, y, z)) //x, y and z is the float of
{
format(string, sizeof(string), "ID: %i", a);
SendClientMessage(playerid, #COLOR#, string);
}
}
}
It will shows the closest players. But there still a little bug where that:
If a player range is 1 (Really close to you), SendClientmessage will say his/her ID for 10 times
If a player range is 2 (Close to you), SendClientMessage will say his/her ID for 9 times
......
Like that.
Hope helps
Re: pls help me: GetClosestPlayers -
Thrarod - 14.04.2010
Its a meter

loads of ids = neart, less ids = far