local chars = getAllChars();
for k,v in pairs(chars) do
local myposx, myposy, myposz = getCharCoordinates(PLAYER_PED)
local targetposx, targetposy, targetposz = getCharCoordinates(v)
local _, targetid = sampGetPlayerIdByCharHandle(v)
if getDistanceBetweenCoords3d(myposx, myposy, myposz, targetposx, targetposy, targetposz) <= radius and PLAYER_PED ~= v then
-- делаешь тут что-то с targetid, это все твои айдишники
end
end