pls help me: GetClosestPlayers
#1

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
Reply
#2

Could have it so it gets the ClosestPlayer for the number 1 person then nearest person to number 2.
Reply
#3

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?
Reply
#4

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
Reply
#5

Its a meter loads of ids = neart, less ids = far
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)