Поднять ближайший пикап / raksamp lite

Статус
В этой теме нельзя размещать новые ответы.
Решение
Lua:
-- Использование: pickUpNearestPickup()
local vector3d = require('vector3d')
require('addon')

function pickUpNearestPickup()
    local pickup_id, distance = nil, math.huge
    local position = vector3d(getPosition()) 
    for id, data in pairs(getAllPickups()) do
        if getDistanceBetweenCoords3d(position, distance.position) < distance then
            pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position)
        end
    end
    if pickup_id then
        sendPickedUpPickup(pickup_id)
    end
    return pickup_id and true or false
end

function getDistanceBetweenCoords3d(point1, point2)
    return math.sqrt((point2.x - point1.x) ^ 2 + (point2.y - point1.y) ^ 2 + (point2.z - point1.z) ^ 2)
end

Dimiano

Потрачен
74
71
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
-- Использование: pickUpNearestPickup()
local vector3d = require('vector3d')
require('addon')

function pickUpNearestPickup()
    local pickup_id, distance = nil, math.huge
    local position = vector3d(getPosition()) 
    for id, data in pairs(getAllPickups()) do
        if getDistanceBetweenCoords3d(position, distance.position) < distance then
            pickup_id, distance = id, getDistanceBetweenCoords3d(position, distance.position)
        end
    end
    if pickup_id then
        sendPickedUpPickup(pickup_id)
    end
    return pickup_id and true or false
end

function getDistanceBetweenCoords3d(point1, point2)
    return math.sqrt((point2.x - point1.x) ^ 2 + (point2.y - point1.y) ^ 2 + (point2.z - point1.z) ^ 2)
end
 
  • Нравится
Реакции: kickflip228
Статус
В этой теме нельзя размещать новые ответы.