Как получить id пикапа по его координатам?

Baklaxa

Новичок
Автор темы
13
2
Версия MoonLoader
.026-beta
хочу получить ид пикапа по его координатам (не по модельке)

есть bool result = isAnyPickupAtCoords(float pickupX, float pickupY, float pickupZ) ,но там только булевое значение
 
Решение
Lua:
function getAllPickups() -- https://www.blast.hk/threads/13380/page-8#post-361600
    local pu = {}
    pPu = sampGetPickupPoolPtr() + 16388
    for i = 0, 4095 do
        local id = readMemory(pPu + 4 * i, 4)
        if id ~= -1 then
            table.insert(pu, sampGetPickupHandleBySampId(i))
        end
    end
    return pu
end

function getPickupAtCoords(x, y, z)
    local result = { handle = nil, dist = math.huge }
    for _, handle in ipairs(getAllPickups()) do
        local px, py, pz = getPickupCoordinates(handle)
        local dist = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
        if dist < result.dist then
            result.dist = dist
            result.handle = handle
        end
    end
    return result.handle...

chapo

tg/inst: @moujeek
Всефорумный модератор
9,234
12,655
Lua:
function getAllPickups() -- https://www.blast.hk/threads/13380/page-8#post-361600
    local pu = {}
    pPu = sampGetPickupPoolPtr() + 16388
    for i = 0, 4095 do
        local id = readMemory(pPu + 4 * i, 4)
        if id ~= -1 then
            table.insert(pu, sampGetPickupHandleBySampId(i))
        end
    end
    return pu
end

function getPickupAtCoords(x, y, z)
    local result = { handle = nil, dist = math.huge }
    for _, handle in ipairs(getAllPickups()) do
        local px, py, pz = getPickupCoordinates(handle)
        local dist = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
        if dist < result.dist then
            result.dist = dist
            result.handle = handle
        end
    end
    return result.handle
end
 
  • Нравится
Реакции: Baklaxa и MLycoris