If you really want the EXACT nearest person to be jailed, aka meaning even if the person is across the other side of the map, then do a for loop outside that for loop:
pawn Код:
for(new a = 0; a <= 10000; a++)
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
new Float:range; //make new float
range = float(a); //convert the integer first for loop variable a into range
if(IsPlayerInRangeOfPoint(i, range, x, y, z))
{
SetPlayerPos(i, 0.0, 0.0, 0.0);
break;
}
}
}
Not recommended by me because I don't know the maximum x, y or z -axis in San Andreas, maybe it will affect the virtual worlds as well.
Improvements on first attempt:
pawn Код:
if(sscanf(params, "u", pid))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new vw = GetPlayerVirtualWorld(playerid);
for(new i = 0; i <= MAX_PLAYERS; i++)
{
vwI = GetPlayerVirtualWorld(i);
if((IsPlayerInRangeOfPoint(i, 3.0, x, y, z)) && (vwI == vw)) //3.0 is the range, change this to whatever you want.
{
SetPlayerPos(i, 0.0, 0.0, 0.0);
break; //or just return 1, it will stop the loop (I think return 1 will do it as well);
}
}
return 1;
}
else
{
//Code for SetPlayerPos(pid...)
return 1;
}
You can also add GetPlayerInterior and check if they are same as well!