-- Возвращает массив с ближайшими игроками в зависимости от дистанции
function getClosestPlayers()
local closestIds = {}
local x, y, z = getCharCoordinates(PLAYER_PED)
for id = 0, maxPlayers do
local streamed, pedID = sampGetCharHandleBySampPlayerId(id)
if streamed and getCharHealth(pedID) > 0 then
local xi, yi, zi = getCharCoordinates(pedID)
local dist = getDistanceBetweenCoords3d(x, y, z, xi, yi, zi)
if dist <= maxDistance then table.insert(closestIds, id) end
end
end
return closestIds
end