Функция которая получает id машин в радиусе

Dark.

Известный
Автор темы
1,742
780
Версия MoonLoader
.026-beta
Знаю как получить ид игроков в радиусе, но хз как получить ид всех машин в заданном радиусе.
 

lorgon

Известный
656
274
Lua:
function getVehiclesInArea3d(x1, y1, z1, x2, y2, z2, sphere)
    local vehicles = {}

    for _, v in ipairs(getAllVehicles()) do
        if isCarInArea3d(v, x1, y1, z1, x2, y2, z2, sphere) then
            table.insert(vehicles, select(2, sampGetVehicleIdByCarHandle(v)))
        end
    end

    return vehicles;
end
Попросили же в радиусе, а не в площади
 
  • Нравится
Реакции: qdIbp

Lance_Sterling

Известный
995
355
Код:
function getVehiclesInArea3d(radius)
    local vehicles = {}

    for _, v in ipairs(getAllVehicles()) do
        local x1, y1, z1, x2, y2, z2 = getCharCoordinates(PLAYER_PED), getCarCoordinates(v)
        if getDistanceBetweenCoords3d(x1, y1, z1, x2, y2, z2) <= radius then
            table.insert(vehicles, select(2, sampGetVehicleIdByCarHandle(v)))
        end
    end

    return vehicles;
end
 
  • Нравится
Реакции: YarikVL, qdIbp и lorgon