Guest User

Points Streamer v2.2

a guest
May 15th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 20.54 KB | None | 0 0
  1. #if defined _W_PS_included
  2.     #endinput
  3. #endif
  4. #define _W_PS_included
  5. #pragma library W_PS
  6. /*============================================================================*\
  7. =======================|      Points Streamer v2.2      |=======================
  8. =======================|      Created by: White_116     |=======================
  9. =======================|        Date: 15.05.2013        |=======================
  10. ================================================================================
  11. native IsValidPoint(pointid);// Существует ли точка
  12. native CreatePoint(Float:x, Float:y, Float:z, Float:r, worldid=-1, interior=-1);// Cоздаёт точку (х, у, z, радиус, вирт.мир, интерьер)
  13. native DestroyPoint(pointid);// Удаляет точку
  14. native DestroyAllPoint();// Удаляет все точки
  15. native SetPointPos(pointid, Float:x, Float:y, Float:z);//Переместить точку
  16. native GetPointPos(pointid, &Float:x, &Float:y, &Float:z);//Узнать координаты точки
  17. native SetPointRadius(pointid, Float:r);//Установить радиус точки
  18. native GetPointRadius(pointid, &Float:r);//Узнать радиус точки
  19. native SetPointInterior(pointid, interior);//Установить интерьер точки
  20. native GetPointInterior(pointid);//Узнать интерьер точки
  21. native SetPointVirtualWorld(pointid, worldid);//Установить вирт.мир точки
  22. native GetPointVirtualWorld(pointid);//Узнать вирт.мир точки
  23. native GetPlayerPoint(playerid, mode=0); //Узнает в какой точке находится игрок (самую близлежащую, самую близлежащую с проверкой радиуса, самую первую которая входит в радиус)
  24. native GetPlayerMultiPoint(playerid, MP[], Size);//Узнает в каких точках находится игрок
  25. native GetVehiclePoint(vehicleid, mode=0);//Узнает в какой точке находится транспорт (самую близлежащую, самую близлежащую с проверкой радиуса, самую первую которая входит в радиус)
  26. native GetVehicleMultiPoint(vehicleid, MP[], Size);//Узнает в каких точках находится транспорт
  27. \*============================================================================*/
  28. #if !defined MAX_POINTS
  29.     #define MAX_POINTS (1000)//Максимальное число точек.
  30. #endif
  31. #if !defined MAX_POINTS_TO_STREAM
  32.     #define MAX_POINTS_TO_STREAM (30)//Количество точек в чанке (MAX 256)
  33. #endif
  34. #if !defined MAX_POINTS_REGION
  35.     #define MAX_POINTS_REGION (3000)//Граница
  36. #endif
  37. #if !defined MAX_POINTS_SETKA_DLINA
  38.     #define MAX_POINTS_SETKA_DLINA (60)//Размер чанка
  39. #endif
  40. #define MAX_POINTS_STORONA_DLINA ((MAX_POINTS_REGION*2)/MAX_POINTS_SETKA_DLINA)
  41.  
  42. new Float:PointX[MAX_POINTS+1],
  43.     Float:PointY[MAX_POINTS+1],
  44.     Float:PointZ[MAX_POINTS+1],
  45.     Float:PointR[MAX_POINTS+1],
  46.     PointXX[MAX_POINTS+1 char],
  47.     PointYY[MAX_POINTS+1 char],
  48.     PointS[9][MAX_POINTS+1 char];
  49.    
  50. #if defined PointWorld
  51.     new PointW[MAX_POINTS+1];
  52. #endif
  53.  
  54. #if defined PointInterior
  55.     new PointI[MAX_POINTS+1];
  56. #endif
  57.    
  58. new Point_Chunk[MAX_POINTS_STORONA_DLINA][MAX_POINTS_STORONA_DLINA][MAX_POINTS_TO_STREAM],
  59.     Point_PointsInChunk[MAX_POINTS_STORONA_DLINA][MAX_POINTS_STORONA_DLINA char],
  60.     Point_Created[MAX_POINTS+1],
  61.     Point_Points;
  62.    
  63. new const Okrug[9][2]={{0,0},{0,1},{0,-2},{1,1},{-2,0},{2,1},{0,-2},{-2,2},{0,-2}};
  64. //==============================================================================
  65. //==============================================================================
  66. //==============================================================================
  67. stock GetChunkPosXY(region,dlina,Float:x,Float:y,&x1,&y1,p=1)
  68. {
  69.     if(p)
  70.     {
  71.         // создадим искуственную границу дальше которой нельзя находится
  72.         if(x<-region)x=-region+1; else if(y>region)y=region-1;
  73.         if(y<-region)y=-region+1; else if(x>region)x=region-1;
  74.     }
  75.     x1=floatround((x+region)/dlina,floatround_floor);
  76.     y1=floatround((y+region)/dlina,floatround_floor);
  77.     return 1;
  78. }
  79.  
  80. stock IsValidPoint(P)
  81. {
  82.     if(Point_Points == 0)return 0;
  83.     if(!(0 < P <= MAX_POINTS))return 0;
  84.     if(PointS[0]{P} == 0xFF)return 0;
  85.     return 1;
  86. }
  87.  
  88. stock Point_sd(Float:x,Float:y,Float:r,X,Y,f[9])
  89. {
  90.     x+=(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA);
  91.     y+=(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA);
  92.     new Float:ox=floatabs(x-(MAX_POINTS_SETKA_DLINA*X));
  93.     new Float:oy=floatabs(y-(MAX_POINTS_SETKA_DLINA*Y));
  94.  
  95.     f[0]=1;
  96.  
  97.     if(ox < r)
  98.     {
  99.         f[4]=1; if(Point_PointsInChunk[X-1]{Y} >= MAX_POINTS_TO_STREAM)return 0;
  100.     }
  101.     if(oy < r)
  102.     {
  103.         f[2]=1; if(Point_PointsInChunk[X]{Y-1} >= MAX_POINTS_TO_STREAM)return 0;
  104.     }
  105.     if(MAX_POINTS_SETKA_DLINA-ox < r)
  106.     {
  107.         f[3]=1; if(Point_PointsInChunk[X+1]{Y} >= MAX_POINTS_TO_STREAM)return 0;
  108.     }
  109.     if(MAX_POINTS_SETKA_DLINA-oy < r)
  110.     {
  111.         f[1]=1; if(Point_PointsInChunk[X]{Y+1} >= MAX_POINTS_TO_STREAM)return 0;
  112.     }
  113.     if(floatsqroot(floatpower(ox, 2) + floatpower(oy, 2)) < r)
  114.     {
  115.         f[8]=1; if(Point_PointsInChunk[X-1]{Y-1} >= MAX_POINTS_TO_STREAM)return 0;
  116.     }
  117.     if(floatsqroot(floatpower(floatsub(MAX_POINTS_SETKA_DLINA, ox), 2) + floatpower(floatabs(oy), 2)) < r)
  118.     {
  119.         f[6]=1; if(Point_PointsInChunk[X-1]{Y+1} >= MAX_POINTS_TO_STREAM)return 0;
  120.     }
  121.     if(floatsqroot(floatpower(floatabs(ox), 2) + floatpower(floatsub(MAX_POINTS_SETKA_DLINA, oy), 2)) < r)
  122.     {
  123.         f[7]=1; if(Point_PointsInChunk[X+1]{Y+1} >= MAX_POINTS_TO_STREAM)return 0;
  124.     }
  125.     if(floatsqroot( floatpower(floatsub(MAX_POINTS_SETKA_DLINA, ox), 2) + floatpower(floatsub(MAX_POINTS_SETKA_DLINA, oy), 2)) < r)
  126.     {
  127.         f[5]=1; if(Point_PointsInChunk[X+1]{Y-1} >= MAX_POINTS_TO_STREAM)return 0;
  128.     }
  129.     return 1;
  130. }
  131.  
  132. stock CreatePoint(Float:x, Float:y, Float:z, Float:r, w=-1, i=-1)
  133. {
  134. //==================== Инициализация...
  135.     if(Point_Points == 0)
  136.     {
  137.         for(new e; e < 9; e++)for(new j=1; j <= MAX_POINTS; j++)PointS[e]{j}=0xFF;
  138.         for(new e; e < MAX_POINTS; e++)Point_Created[e]=e+1;
  139.         Point_Points=1;
  140.     }
  141. //==================== проверяем, можно ли добавить точку...
  142.     if(Point_Points >= MAX_POINTS)
  143.     {
  144.         #if defined DeBug
  145.             printf("W_PS-Ошибка: Количество точек привышает максимально допустимого значения MAX_POINTS =%d=", MAX_POINTS);
  146.         #endif
  147.         return 0;
  148.     }
  149.     new ffg[9],X,Y,P=Point_Created[MAX_POINTS-Point_Points];
  150. //==================== проверяем, можно ли добавить точку...
  151.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA,MAX_POINTS_SETKA_DLINA, x,y, X,Y);// узнаём к какому квадрату относится точка
  152.     if(Point_sd(x,y,r,X,Y,ffg) == 0)
  153.     {
  154.         #if defined DeBug
  155.             printf("W_PS-Ошибка: Чанк =%d-%d= или соседний заполнен, придел MAX_POINTS_TO_STREAM =%d=", X,Y, MAX_POINTS_TO_STREAM);
  156.         #endif
  157.         return -1;//    если перебор точек на 1 квадрат
  158.     }
  159. //==================== добовляем данные точки...
  160.     #if defined PointWorld
  161.     if(w < -1)PointW[P]=-w; else PointW[P]=w;
  162.     #else
  163.     if(w != -1)
  164.     {
  165.         #if defined DeBug
  166.             printf("W_PS-Ошибка: Поддержка вирт.миров отключена! Точка =%d=",P);
  167.         #endif
  168.         return -2;
  169.     }
  170.     #endif
  171. //====================
  172.     #if defined PointInterior
  173.     if(i < -1)PointI[P]=-i; else PointI[P]=i;
  174.     #else
  175.     if(i != -1)
  176.     {
  177.         #if defined DeBug
  178.             printf("W_PS-Ошибка: Поддержка интерьеров отключена! Точка =%d=",P);
  179.         #endif
  180.         return -3;
  181.     }
  182.     #endif
  183. //====================
  184.     if(r < 0.0)PointR[P]=-r; else PointR[P]=r;
  185.     #if defined DeBug
  186.         if(PointR[P] >= MAX_POINTS_SETKA_DLINA)printf("W_PS-Предупреждение:Точка =%d=, радиус привышает %d. Возможно ненахождение точки!",P, MAX_POINTS_SETKA_DLINA);
  187.     #endif
  188.     PointX[P]=x,
  189.     PointY[P]=y,
  190.     PointZ[P]=z,
  191.     Point_Created[MAX_POINTS-Point_Points]=0;//     запомним что свободной точки нет
  192.     Point_Points++;//                               запомним сколько всего точек
  193.     PointXX{P}=X,
  194.     PointYY{P}=Y;
  195.     for(new t=0; t < 9; t++)
  196.     {
  197.         X+=Okrug[t][0]; Y+=Okrug[t][1];
  198.         if(!ffg[t])continue;
  199.         PointS[t]{P}=Point_PointsInChunk[X]{Y};
  200.         Point_PointsInChunk[X]{Y}++;//              запомним количество точек в квадрате
  201.         Point_Chunk[X][Y][PointS[t]{P}]=P;//        запомним ид точки
  202.     }
  203.  
  204.     return P;//                                     Отправим ид точки
  205. }
  206.  
  207. stock DestroyAllPoint()
  208. {
  209.     Point_Points=0;//                               Запомним сколько всего точек
  210.     for(new i; i < 9; i++)for(new j=1; j <= MAX_POINTS; j++)PointS[i]{j}=0xFF;
  211.     for(new j; j < MAX_POINTS_STORONA_DLINA; j++)for(new k; k < MAX_POINTS_STORONA_DLINA; k++)Point_PointsInChunk[j]{k}=0;
  212.     return 1;
  213. }
  214.  
  215. stock DestroyPoint(P)
  216. {
  217.     if(!IsValidPoint(P))
  218.     {
  219.         #if defined DeBug
  220.             printf("W_PS-Ошибка: Точки =%d= не существует. Отмена удаления.", P);
  221.         #endif
  222.         return 0;
  223.     }
  224.     Point_Points--;//                               Запомним сколько всего точек
  225.     Point_Created[MAX_POINTS-Point_Points]=P;
  226.    
  227.     new X=PointXX{P};
  228.     new Y=PointYY{P};
  229.     for(new i; i < 9; i++)
  230.     {
  231.         X+=Okrug[i][0]; Y+=Okrug[i][1];//           Окружные чанки
  232.         if(PointS[i]{P} == 0xFF)continue;//         Если точки нет
  233.         new K=Point_PointsInChunk[X]{Y}--;//        Запомним количество точек в квадрате
  234.         Point_Chunk[X][Y][PointS[i]{P}]=0;//        Обнулим удалёную точку
  235.         new P2=Point_Chunk[X][Y][K];//              Достанем ид крайней точки
  236.         if(P2 == 0)PointS[i]{P}=0xFF;//             Наша точка оказаласть крайней, Запомним что точки не существует
  237.         else
  238.         {
  239.             Point_Chunk[X][Y][K]=0;//               Обнулим Крайнюю точку
  240.             Point_Chunk[X][Y][PointS[i]{P}]=P2;//   Внесём ид крайней точки в удалёную
  241.             PointS[i]{P2}=PointS[i]{P};//           Изменим позицию крайней точки
  242.             PointS[i]{P}=0xFF;//                    Запомним что точки не существует
  243.         }
  244.     }
  245.     return 1;
  246. }
  247.  
  248. stock SetPointPos(P, Float:x, Float:y, Float:z)
  249. {
  250.     if(!IsValidPoint(P))
  251.     {
  252.         #if defined DeBug
  253.             printf("W_PS-Ошибка: Точки =%d= не существует. Отмена перемещения.", P);
  254.         #endif
  255.         return 0;
  256.     }
  257.     new X,Y;
  258.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA,MAX_POINTS_SETKA_DLINA, x,y, X,Y);// узнаём к какому квадрату будет относиться точка
  259.     new Z=X;
  260.     new U=Y;
  261.     if(PointXX{P}!=X || PointYY{P}!=Y)
  262.     {
  263.         for(new t; t < 9; t++)
  264.         {
  265.             Z+=Okrug[t][0]; U+=Okrug[t][1];
  266.             if(PointS[t]{P}==0xFF)continue;
  267.             //==================== проверяем, можно ли добавить точку...
  268.             if(Point_PointsInChunk[Z]{U} >= MAX_POINTS_TO_STREAM)
  269.             {
  270.                 #if defined DeBug
  271.                     printf("W_PS-Ошибка: Чанк =%d-%d= заполнен, придел MAX_POINTS_TO_STREAM =%d=. Перемещение точки %d в =%d-%d= отменено.", Z,U, MAX_POINTS_TO_STREAM, P, X,Y);
  272.                 #endif
  273.                 return -1;
  274.             }
  275.         }
  276.         new OX=PointXX{P};
  277.         new OY=PointYY{P};
  278.         Z=X;    U=Y;
  279.         for(new t; t < 9; t++)
  280.         {
  281.             OX+=Okrug[t][0];    OY+=Okrug[t][1];
  282.             Z+=Okrug[t][0];     U+=Okrug[t][1];
  283.             if(PointS[t]{P}==0xFF)continue;
  284.             //==================== перегрупперуем старый квадрат от старой точки
  285.             new K=Point_PointsInChunk[OX]{OY}--;//              Запомним количество точек в квадрате
  286.             Point_Chunk[OX][OY][PointS[t]{P}]=0;//              Обнулим удалёную точку
  287.             new P2=Point_Chunk[OX][OY][K];//                    Достанем ид крайней точки
  288.             if(P2 != 0)
  289.             {
  290.                 Point_Chunk[OX][OY][K]=0;//                     Обнулим Крайнюю точку
  291.                 Point_Chunk[OX][OY][PointS[t]{P}]=P2;//         Внесём ид крайней точки в удалёную
  292.                 PointS[t]{P2}=PointS[t]{P};//                   Изменим позицию крайней точки
  293.             }
  294.             //==================== добовляем данные точки...
  295.             Point_Chunk[Z][U][Point_PointsInChunk[Z]{U}]=P;//   запомним ид точки
  296.             PointS[t]{P}=Point_PointsInChunk[Z]{U};
  297.             Point_PointsInChunk[Z]{U}++;//                      запомним количество точек в квадрате
  298.         }
  299.         PointXX{P}=X;
  300.         PointYY{P}=Y;
  301.     }
  302.     PointX[P]=x; PointY[P]=y; PointZ[P]=z;
  303.     return 1;
  304. }
  305.  
  306. stock GetPointPos(P, &Float:x, &Float:y, &Float:z)
  307. {
  308.     if(!IsValidPoint(P))
  309.     {
  310.         #if defined DeBug
  311.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить позицию.", P);
  312.         #endif
  313.         return 0;
  314.     }
  315.     x=PointX[P]; y=PointY[P]; z=PointZ[P];
  316.     return 1;
  317. }
  318.  
  319. stock SetPointRadius(P,Float:r)
  320. {
  321.     if(!IsValidPoint(P))
  322.     {
  323.         #if defined DeBug
  324.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  325.         #endif
  326.         return 0;
  327.     }
  328.     if(r < 0.0)PointR[P]=-r; else PointR[P]=r;
  329.     return 1;
  330. }
  331.  
  332. stock GetPointRadius(P,&Float:r)
  333. {
  334.     if(!IsValidPoint(P))
  335.     {
  336.         #if defined DeBug
  337.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  338.         #endif
  339.         return 0;
  340.     }
  341.     r=PointR[P];
  342.     return 1;
  343. }
  344.  
  345. #if defined PointWorld
  346.     stock SetPointVirtualWorld(P, w)
  347.     {
  348.         if(!IsValidPoint(P))
  349.         {
  350.             #if defined DeBug
  351.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  352.             #endif
  353.             return 0;
  354.         }
  355.         if(w < -1)PointW[P]=-w; else PointW[P]=w;
  356.         return 1;
  357.     }
  358.  
  359.     stock GetPointVirtualWorld(P)
  360.     {
  361.         if(!IsValidPoint(P))
  362.         {
  363.             #if defined DeBug
  364.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  365.             #endif
  366.             return -2;
  367.         }
  368.         return PointW[P];
  369.     }
  370. #endif
  371.  
  372. #if defined PointInterior
  373.     stock SetPointInterior(P, i)
  374.     {
  375.         if(!IsValidPoint(P))
  376.         {
  377.             #if defined DeBug
  378.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  379.             #endif
  380.             return 0;
  381.         }
  382.         if(i < -1)PointI[P]=-i; else PointI[P]=i;
  383.         return 1;
  384.     }
  385.  
  386.     stock GetPointInterior(P)
  387.     {
  388.         if(!IsValidPoint(P))
  389.         {
  390.             #if defined DeBug
  391.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  392.             #endif
  393.             return 0;
  394.         }
  395.         return PointI[P];
  396.     }
  397. #endif
  398.  
  399. //==============================================================================
  400. //==============================================================================
  401. //==============================================================================
  402. stock GetPlayerPoint(playerid, r=0)
  403. {
  404.     new Float:x,Float:y, Float:z, X,Y,P,P2;
  405.     GetPlayerPos(playerid,x,y,z);
  406.     #if defined PointWorld
  407.     new WorldID=GetPlayerVirtualWorld(playerid);
  408.     #endif
  409.    
  410.     #if defined PointInterior
  411.     new InteriorID=GetPlayerInterior(playerid);
  412.     #endif
  413.     z=1000.0;
  414.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  415. //--------------------------
  416.     if(r == 2)
  417.     {
  418.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  419.         {
  420.             P=Point_Chunk[X][Y][OP];
  421.             #if defined PointWorld
  422.             if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  423.             #endif
  424.             #if defined PointInterior
  425.             if(InteriorID != PointI[P] || PointI[P]!=-1)continue;
  426.             #endif
  427.             if(IsPlayerInRangeOfPoint(playerid, PointR[P], PointX[P], PointY[P], PointZ[P]))return P;
  428.         }
  429.     }
  430.     else if(r == 1)
  431.     {
  432.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  433.         {
  434.             P=Point_Chunk[X][Y][OP];
  435.             #if defined PointWorld
  436.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  437.             #endif
  438.             #if defined PointInterior
  439.             if(InteriorID != PointI[P] && PointI[P]!=-1)continue;
  440.             #endif
  441.  
  442.             y=GetPlayerDistanceFromPoint(playerid, PointX[P], PointY[P], PointZ[P]);
  443.             if(y < z)
  444.             {
  445.                 z=y; P2=P;
  446.             }
  447.         }
  448.     }
  449.     else
  450.     {
  451.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  452.         {
  453.             P=Point_Chunk[X][Y][OP];
  454.             #if defined PointWorld
  455.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  456.             #endif
  457.             #if defined PointInterior
  458.             if(InteriorID != PointI[P] && PointI[P]!=-1)continue;
  459.             #endif
  460.             y=GetPlayerDistanceFromPoint(playerid, PointX[P], PointY[P], PointZ[P]);
  461.             if(y > PointR[P])continue;
  462.             if(y < z)
  463.             {
  464.                 z=y; P2=P;
  465.             }
  466.         }
  467.     }
  468.     return P2;
  469. }
  470.  
  471. stock GetPlayerMultiPoint(playerid, MP[], S)
  472. {
  473.     new Float:x,Float:y, Float:z, X,Y,P,K;
  474.     GetPlayerPos(playerid,x,y,z);
  475.     #if defined PointWorld
  476.     new WorldID=GetPlayerVirtualWorld(playerid);
  477.     #endif
  478.  
  479.     #if defined PointInterior
  480.     new InteriorID=GetPlayerInterior(playerid);
  481.     #endif
  482.     z=1000.0;
  483.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  484. //--------------------------
  485.     for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  486.     if(K < S)
  487.     {
  488.         P=Point_Chunk[X][Y][OP];
  489.         #if defined PointWorld
  490.         if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  491.         #endif
  492.         #if defined PointInterior
  493.         if(InteriorID != PointI[P] || PointI[P]!=-1)continue;
  494.         #endif
  495.        
  496.         if(IsPlayerInRangeOfPoint(playerid, PointR[P], PointX[P], PointY[P], PointZ[P]))
  497.         {
  498.             MP[K]=P; K++;
  499.         }
  500.     }
  501.     return K;
  502. }
  503. //==============================================================================
  504. stock GetVehiclePoint(vehicleid, r=0)
  505. {
  506.     new Float:x,Float:y, Float:z, X,Y,P,P2;
  507.     GetVehiclePos(vehicleid,x,y,z);
  508.     #if defined PointWorld
  509.     new WorldID=GetVehicleVirtualWorld(vehicleid);
  510.     #endif
  511.  
  512.     z=1000.0;
  513.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  514. //--------------------------
  515.     if(r == 2)
  516.     {
  517.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  518.         {
  519.             P=Point_Chunk[X][Y][OP];
  520.             #if defined PointWorld
  521.             if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  522.             #endif
  523.  
  524.             if(GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]) <= PointR[P])return P;
  525.         }
  526.     }
  527.     else if(r == 1)
  528.     {
  529.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  530.         {
  531.             P=Point_Chunk[X][Y][OP];
  532.             #if defined PointWorld
  533.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  534.             #endif
  535.  
  536.             y=GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]);
  537.             if(y < z)
  538.             {
  539.                 z=y; P2=P;
  540.             }
  541.         }
  542.     }
  543.     else
  544.     {
  545.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  546.         {
  547.             P=Point_Chunk[X][Y][OP];
  548.             #if defined PointWorld
  549.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  550.             #endif
  551.  
  552.             y=GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]);
  553.             if(y > PointR[P])continue;
  554.             if(y < z)
  555.             {
  556.                 z=y; P2=P;
  557.             }
  558.         }
  559.     }
  560.     return P2;
  561. }
  562.  
  563. stock GetVehicleMultiPoint(vehicle, MP[], S)
  564. {
  565.     new Float:x,Float:y, Float:z, X,Y,P,K;
  566.     GetVehiclePos(vehicleid,x,y,z);
  567.     #if defined PointWorld
  568.     new WorldID=GetVehicleVirtualWorld(vehicleid);
  569.     #endif
  570.  
  571.     z=1000.0;
  572.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  573. //--------------------------
  574.     for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  575.     if(K < S)
  576.     {
  577.         P=Point_Chunk[X][Y][OP];
  578.         #if defined PointWorld
  579.         if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  580.         #endif
  581.  
  582.         if(GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]) <= PointR[P])
  583.         {
  584.             MP[K]=P; K++;
  585.         }
  586.     }
  587.     return K;
  588. }
  589.  
  590. #undef MAX_POINTS_TO_STREAM
  591. #undef MAX_POINTS_REGION
  592. #undef MAX_POINTS_SETKA_DLINA
  593. #undef MAX_POINTS_STORONA_DLINA
Add Comment
Please, Sign In to add comment