local sampev = require('samp.events')
local pickups = {}
function onRunCommand(cmd)
if cmd == '!asd' then
pickups = {}
local x, y, z = getBotPosition()
for k, v in pairs(getAllPickups()) do
table.insert(pickups, {distance = getDist(x, y, z, v.position.x, v.position.y, v.position.z), x = v.position.x, y = v.position.y, z = v.position.z})
print(getDist(x, y, z, v.position.x, v.position.y, v.position.z))
end
if #pickups ~= 0 then
table.sort(pickups, function(a, b) return a[1] < b[1] end)
coordStart(pickups[1].x, pickups[1].y, pickups[1].z, 1000, 5, false)
sendKey(1024)
end
end
end
function sendKey(id)
key = id
updateSync()
end
function sampev.onSendPlayerSync(data)
if key then
data.keysData = key
key = nil
end
end
function getDist(x1, y1, z1, x2, y2, z2)
return math.sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
end