2023-07-09 03:07:46 +02:00
|
|
|
function NDCore.GetPlayersFromCoords(distance, coords)
|
2022-12-27 12:33:36 -08:00
|
|
|
if coords then
|
2023-07-09 03:07:46 +02:00
|
|
|
coords = type(coords) == "table" and vec3(coords.x, coords.y, coords.z) or coords
|
2022-12-27 12:33:36 -08:00
|
|
|
else
|
2023-01-03 18:18:54 -08:00
|
|
|
coords = GetEntityCoords(PlayerPedId())
|
2022-12-27 12:33:36 -08:00
|
|
|
end
|
|
|
|
|
distance = distance or 5
|
|
|
|
|
local closePlayers = {}
|
2023-01-03 18:18:54 -08:00
|
|
|
local players = GetActivePlayers()
|
2023-01-03 18:24:38 -08:00
|
|
|
for _, player in ipairs(players) do
|
2022-12-27 12:33:36 -08:00
|
|
|
local target = GetPlayerPed(player)
|
|
|
|
|
local targetCoords = GetEntityCoords(target)
|
|
|
|
|
local targetdistance = #(targetCoords - coords)
|
|
|
|
|
if targetdistance <= distance then
|
|
|
|
|
closePlayers[#closePlayers + 1] = player
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return closePlayers
|
|
|
|
|
end
|