import { GetDistanceBetweenPoints } from './GetDistanceBetweenPoints';

export function GetNearbyPlayers(position: Vector3, range: number, dimension: number = 0): PlayerMp[] {
    const nearbyPlayers: PlayerMp[] = [];

    mp.players.forEach((player) => {
        if (!player || !mp.players.exists(player)) return;
        if (player.dimension !== dimension) return;
        if (GetDistanceBetweenPoints(player.position, position) <= range) {
            nearbyPlayers.push(player);
        }
    });

    return nearbyPlayers;
}
