local id, distance, model, x, y, z = getNearestPickup()
if distance < 2 then -- расстояние не точное
print(model)
end
function getNearestPickup() -- правка из https://www.blast.hk/threads/13380/page-17#post-698745
local pickups = {}
local x, y, z = getCharCoordinates(playerPed)
for i, v in ipairs(getAllPickups()) do
local px, py, pz = getPickupCoordinates(v)
table.insert(pickups, {sampGetPickupSampIdByHandle(v), getDistanceBetweenCoords3d(px, py, pz, x, y, z), getPickupModel(v), px, py, pz})
end
table.sort(pickups, function(a, b) return a[2] < b[2] end)
return unpack(pickups[1])
end
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