function getPosNearPlr(plr)
local sorted = {}
local cartable={}
for k,v in ipairs(getElementsByType('vehicle'))do
local xv,yv,zv=getElementPosition(v)
table.insert(cartable,{xv,yv,zv})
end
local x, y, z = getElementPosition(plr)
for i, v in ipairs(cartable) do
local d = getDistanceBetweenPoints3D(x, y, z, v[1], v[2], v[3])
sorted[i] = {pos = v, dist = d}
end
table.sort(sorted, function(a, b) return a.dist < b.dist end)
for i=1, #sorted do
cartable[i] = sorted[i].pos
end
return sorted[1].pos
end
addCommandHandler('setcarblip',function(plr)
local carpos=getPosNearPlr(plr)
createBlip(carpos[1],carpos[2],carpos[3],15)
outputChatBox(carpos[1]..','..carpos[2]..','..carpos[3],plr)
end)
بالتوفيق غير مجرب