телепорт по машинам

uc_Rf_221.2

Новичок
Автор темы
23
3
Версия MoonLoader
.026-beta
я хочу сделать так, чтобы скрипт тпхался в машину, не в машины, а в машину(которая находиться вблизи). Помогите пж
 

Rice.

https://t.me/riceoff
Модератор
1,691
1,440
я хочу сделать так, чтобы скрипт тпхался в машину, не в машины, а в машину(которая находиться вблизи). Помогите пж
Функция для поиска машины в некотором радиусе:
function findCarRadius(radius)
    local log = {}
    for k, v in pairs(getAllVehicles()) do
        if doesVehicleExist(v) then
            local mx, my, mz = getCharCoordinates(PLAYER_PED)
            local cx, cy, cz = getCarCoordinates(v)
            local dist = getDistanceBetweenCoords3d(mx, my, mz, cx, cy, cz)
            if dist <= radius then
                table.insert(log, {v, dist})
            end
        end
    end
    if #log > 0 then
        table.sort(log, function(a, b) return (a[2] < b[2]) end)
        return log[1][1]
    end
    return nil
end
Пример:
sampRegisterChatCommand('tp_car', function()
    local handle = findCarRadius(15)
    if handle ~= nil then
        warpCharIntoCar(PLAYER_PED, handle)
    end
end)