[Lua] Как найти ближайшие координаты из таблицы?

Kozlik Mad

Участник
Автор темы
131
6
Версия MoonLoader
.026-beta
[Lua] Как найти ближайшие координаты из таблицы?
У меня есть таблица:
Lua:
local points = {
    {494.2127,900.2444,-31.2790,172.1830},
    {492.7954,871.5478,-31.7056,180.9564},
    {494.6249,858.0733,-29.8713,196.9365},
    {501.4121,847.6720,-29.6383,215.4234},
    {509.1335,837.0791,-27.3420,210.4099},
    {515.1370,819.7126,-24.4549,171.2428},
    {510.0278,809.6243,-22.6350,148.9960},
    {503.5203,798.8848,-21.9509,174.6896},
    {514.4619,791.4207,-21.8113,237.0437},
    {552.2419,777.5346,-18.2759,250.2040},
    {565.0500,772.3365,-16.8893,246.7572},
    {546.6044,787.3830,-18.9529,66.9256},
    {547.7505,798.7891,-24.9084,320.7046},
    {562.6649,800.2211,-28.3372,262.1106},
    {596.1277,791.9645,-31.5205,258.0372},
    {625.3763,789.9603,-31.5017,272.1375},
    {651.3365,786.5530,-30.2063,277.1511},
    {677.9435,796.1486,-30.2138,291.8781},
    {701.8917,818.2128,-30.2099,332.6120},
    {711.0311,851.8719,-30.2094,351.7255},
    {715.6677,887.1207,-26.9096,30.8924},
    {697.0997,919.8445,-30.2819,28.3857},
    {683.6564,938.1956,-30.2115,48.1259},
    {664.0256,948.1311,-34.2292,82.2795},
    {647.3246,947.7401,-34.9773,59.3334},
    {633.7614,946.7762,-35.4107,85.4128},
    {609.8827,948.2834,-33.1926,89.4862},
    {592.9803,947.0738,-31.6510,96.3796},
    {540.3727,937.8636,-24.0167,99.5130},
    {520.2986,945.6498,-24.8544,344.205},
    {519.1691,962.1794,-24.0629,48.7524},
    {519.4039,970.9621,-23.8493,284.6712},
    {539.1528,966.4783,-21.0728,242.9973},
    {575.4581,963.3486,-18.6970,270.5711},
    {556.9150,957.0627,-19.0067,96.3561},
    {532.9533,950.1041,-21.8653,109.2029},
    {512.5461,935.1605,-27.0458,131.7631},
    {500.7166,921.6392,-29.3155,143.6698},
    {493.7206,907.7218,-30.9449,172.8101},
    {488.0671,891.8292,-30.8942,155.8900},
    {474.1705,879.7705,-29.8426,104.5029},
}
 
Решение
а че тебе нужно то тогда? тебе скинули то что ты описал
Он наверное хотел только CTRL + C и CTRL + V
оно не работает
Как не работает? Точнее? Код приложи который у тебя не работает?
В твоем случае надо дописать x,y,z
1EC37758-7C34-4C42-9DEB-C21CB1643E85.png
Lua:
local points = {
    {494.2127,900.2444,-31.2790,172.1830},
    {492.7954,871.5478,-31.7056,180.9564},
    {494.6249,858.0733,-29.8713,196.9365},
    {501.4121,847.6720,-29.6383,215.4234},
    {509.1335,837.0791,-27.3420,210.4099},
    {515.1370,819.7126,-24.4549,171.2428},
    {510.0278,809.6243,-22.6350,148.9960},
    {503.5203,798.8848,-21.9509,174.6896},
    {514.4619,791.4207,-21.8113,237.0437},
    {552.2419,777.5346,-18.2759,250.2040},
    {565.0500,772.3365,-16.8893,246.7572}...

YarikVL

Известный
Проверенный
4,750
1,815
[Lua] Как найти ближайшие координаты из таблицы?
У меня есть таблица:
Lua:
local points = {
    {494.2127,900.2444,-31.2790,172.1830},
    {492.7954,871.5478,-31.7056,180.9564},
    {494.6249,858.0733,-29.8713,196.9365},
    {501.4121,847.6720,-29.6383,215.4234},
    {509.1335,837.0791,-27.3420,210.4099},
    {515.1370,819.7126,-24.4549,171.2428},
    {510.0278,809.6243,-22.6350,148.9960},
    {503.5203,798.8848,-21.9509,174.6896},
    {514.4619,791.4207,-21.8113,237.0437},
    {552.2419,777.5346,-18.2759,250.2040},
    {565.0500,772.3365,-16.8893,246.7572},
    {546.6044,787.3830,-18.9529,66.9256},
    {547.7505,798.7891,-24.9084,320.7046},
    {562.6649,800.2211,-28.3372,262.1106},
    {596.1277,791.9645,-31.5205,258.0372},
    {625.3763,789.9603,-31.5017,272.1375},
    {651.3365,786.5530,-30.2063,277.1511},
    {677.9435,796.1486,-30.2138,291.8781},
    {701.8917,818.2128,-30.2099,332.6120},
    {711.0311,851.8719,-30.2094,351.7255},
    {715.6677,887.1207,-26.9096,30.8924},
    {697.0997,919.8445,-30.2819,28.3857},
    {683.6564,938.1956,-30.2115,48.1259},
    {664.0256,948.1311,-34.2292,82.2795},
    {647.3246,947.7401,-34.9773,59.3334},
    {633.7614,946.7762,-35.4107,85.4128},
    {609.8827,948.2834,-33.1926,89.4862},
    {592.9803,947.0738,-31.6510,96.3796},
    {540.3727,937.8636,-24.0167,99.5130},
    {520.2986,945.6498,-24.8544,344.205},
    {519.1691,962.1794,-24.0629,48.7524},
    {519.4039,970.9621,-23.8493,284.6712},
    {539.1528,966.4783,-21.0728,242.9973},
    {575.4581,963.3486,-18.6970,270.5711},
    {556.9150,957.0627,-19.0067,96.3561},
    {532.9533,950.1041,-21.8653,109.2029},
    {512.5461,935.1605,-27.0458,131.7631},
    {500.7166,921.6392,-29.3155,143.6698},
    {493.7206,907.7218,-30.9449,172.8101},
    {488.0671,891.8292,-30.8942,155.8900},
    {474.1705,879.7705,-29.8426,104.5029},
}
Вот есть: https://www.blast.hk/threads/145420/post-1115893
 

YarikVL

Известный
Проверенный
4,750
1,815
а че тебе нужно то тогда? тебе скинули то что ты описал
Он наверное хотел только CTRL + C и CTRL + V
оно не работает
Как не работает? Точнее? Код приложи который у тебя не работает?
В твоем случае надо дописать x,y,z
1EC37758-7C34-4C42-9DEB-C21CB1643E85.png
Lua:
local points = {
    {494.2127,900.2444,-31.2790,172.1830},
    {492.7954,871.5478,-31.7056,180.9564},
    {494.6249,858.0733,-29.8713,196.9365},
    {501.4121,847.6720,-29.6383,215.4234},
    {509.1335,837.0791,-27.3420,210.4099},
    {515.1370,819.7126,-24.4549,171.2428},
    {510.0278,809.6243,-22.6350,148.9960},
    {503.5203,798.8848,-21.9509,174.6896},
    {514.4619,791.4207,-21.8113,237.0437},
    {552.2419,777.5346,-18.2759,250.2040},
    {565.0500,772.3365,-16.8893,246.7572},
    {546.6044,787.3830,-18.9529,66.9256},
    {547.7505,798.7891,-24.9084,320.7046},
    {562.6649,800.2211,-28.3372,262.1106},
    {596.1277,791.9645,-31.5205,258.0372},
    {625.3763,789.9603,-31.5017,272.1375},
    {651.3365,786.5530,-30.2063,277.1511},
    {677.9435,796.1486,-30.2138,291.8781},
    {701.8917,818.2128,-30.2099,332.6120},
    {711.0311,851.8719,-30.2094,351.7255},
    {715.6677,887.1207,-26.9096,30.8924},
    {697.0997,919.8445,-30.2819,28.3857},
    {683.6564,938.1956,-30.2115,48.1259},
    {664.0256,948.1311,-34.2292,82.2795},
    {647.3246,947.7401,-34.9773,59.3334},
    {633.7614,946.7762,-35.4107,85.4128},
    {609.8827,948.2834,-33.1926,89.4862},
    {592.9803,947.0738,-31.6510,96.3796},
    {540.3727,937.8636,-24.0167,99.5130},
    {520.2986,945.6498,-24.8544,344.205},
    {519.1691,962.1794,-24.0629,48.7524},
    {519.4039,970.9621,-23.8493,284.6712},
    {539.1528,966.4783,-21.0728,242.9973},
    {575.4581,963.3486,-18.6970,270.5711},
    {556.9150,957.0627,-19.0067,96.3561},
    {532.9533,950.1041,-21.8653,109.2029},
    {512.5461,935.1605,-27.0458,131.7631},
    {500.7166,921.6392,-29.3155,143.6698},
    {493.7206,907.7218,-30.9449,172.8101},
    {488.0671,891.8292,-30.8942,155.8900},
    {474.1705,879.7705,-29.8426,104.5029},
}
local min = math.huge
pos = {getCharCoordinates(PLAYER_PED)} -- позиция игрока
function minim(arg)
  for l,k in pairs(arg) do
    cord = math.sqrt((pos[1]-k[1])^2+(pos[2]-k[2])^2+(pos[3]-k[3])^2)
    --print(l,cord)
    min = math.min(min,cord)
    x = k[1]
    y = k[2]
    z = k[3]
  end
  return min, x, y, z
end
print(minim(points))
 
  • Нравится
Реакции: sdfy и Kozlik Mad