Guest User

Points Streamer v2.3

a guest
May 17th, 2013
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 20.36 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.3      |=======================
  8. =======================|      Created by: White_116     |=======================
  9. =======================|        Date: 17.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 (100)//Количество точек в чанке (MAX 255)
  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 Z,U,ffg[9];;
  258.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA,MAX_POINTS_SETKA_DLINA, x,y, Z,U);// узнаём к какому квадрату будет относиться точка
  259.     if(Point_sd(x,y,PointR[P],Z,U,ffg) == 0)
  260.     {
  261.         #if defined DeBug
  262.             printf("W_PS-Ошибка: Чанк =%d-%d= или соседний заполнен, придел MAX_POINTS_TO_STREAM =%d=", X,Y, MAX_POINTS_TO_STREAM);
  263.         #endif
  264.         return -1;//    если перебор точек на 1 квадрат
  265.     }
  266.    
  267.     new X=PointXX{P};
  268.     new Y=PointYY{P};
  269.     for(new i; i < 9; i++)
  270.     {
  271.         X+=Okrug[i][0]; Y+=Okrug[i][1];//           Окружные чанки
  272.         if(PointS[i]{P} == 0xFF)continue;//         Если точки нет
  273.         new K=Point_PointsInChunk[X]{Y}--;//        Запомним количество точек в квадрате
  274.         Point_Chunk[X][Y][PointS[i]{P}]=0;//        Обнулим удалёную точку
  275.         new P2=Point_Chunk[X][Y][K];//              Достанем ид крайней точки
  276.         if(P2 == 0)PointS[i]{P}=0xFF;//             Наша точка оказаласть крайней, Запомним что точки не существует
  277.         else
  278.         {
  279.             Point_Chunk[X][Y][K]=0;//               Обнулим Крайнюю точку
  280.             Point_Chunk[X][Y][PointS[i]{P}]=P2;//   Внесём ид крайней точки в удалёную
  281.             PointS[i]{P2}=PointS[i]{P};//           Изменим позицию крайней точки
  282.             PointS[i]{P}=0xFF;//                    Запомним что точки не существует
  283.         }
  284.     }
  285.  
  286.     for(new t=0; t < 9; t++)
  287.     {
  288.         Z+=Okrug[t][0]; U+=Okrug[t][1];
  289.         if(!ffg[t])continue;
  290.         PointS[t]{P}=Point_PointsInChunk[Z]{U};
  291.         Point_PointsInChunk[Z]{U}++;//              запомним количество точек в квадрате
  292.         Point_Chunk[Z][U][PointS[t]{P}]=P;//        запомним ид точки
  293.     }
  294.     PointXX{P}=X;PointYY{P}=Y;
  295.     PointX[P]=x; PointY[P]=y; PointZ[P]=z;
  296.     return 1;
  297. }
  298.  
  299. stock GetPointPos(P, &Float:x, &Float:y, &Float:z)
  300. {
  301.     if(!IsValidPoint(P))
  302.     {
  303.         #if defined DeBug
  304.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить позицию.", P);
  305.         #endif
  306.         return 0;
  307.     }
  308.     x=PointX[P]; y=PointY[P]; z=PointZ[P];
  309.     return 1;
  310. }
  311.  
  312. stock SetPointRadius(P,Float:r)
  313. {
  314.     if(!IsValidPoint(P))
  315.     {
  316.         #if defined DeBug
  317.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  318.         #endif
  319.         return 0;
  320.     }
  321.     if(r < 0.0)PointR[P]=-r; else PointR[P]=r;
  322.     return 1;
  323. }
  324.  
  325. stock GetPointRadius(P,&Float:r)
  326. {
  327.     if(!IsValidPoint(P))
  328.     {
  329.         #if defined DeBug
  330.             printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  331.         #endif
  332.         return 0;
  333.     }
  334.     r=PointR[P];
  335.     return 1;
  336. }
  337.  
  338. #if defined PointWorld
  339.     stock SetPointVirtualWorld(P, w)
  340.     {
  341.         if(!IsValidPoint(P))
  342.         {
  343.             #if defined DeBug
  344.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  345.             #endif
  346.             return 0;
  347.         }
  348.         if(w < -1)PointW[P]=-w; else PointW[P]=w;
  349.         return 1;
  350.     }
  351.  
  352.     stock GetPointVirtualWorld(P)
  353.     {
  354.         if(!IsValidPoint(P))
  355.         {
  356.             #if defined DeBug
  357.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  358.             #endif
  359.             return -2;
  360.         }
  361.         return PointW[P];
  362.     }
  363. #endif
  364.  
  365. #if defined PointInterior
  366.     stock SetPointInterior(P, i)
  367.     {
  368.         if(!IsValidPoint(P))
  369.         {
  370.             #if defined DeBug
  371.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно установить радиус.", P);
  372.             #endif
  373.             return 0;
  374.         }
  375.         if(i < -1)PointI[P]=-i; else PointI[P]=i;
  376.         return 1;
  377.     }
  378.  
  379.     stock GetPointInterior(P)
  380.     {
  381.         if(!IsValidPoint(P))
  382.         {
  383.             #if defined DeBug
  384.                 printf("W_PS-Ошибка: Точки =%d= не существует. Не возможно определить радиус.", P);
  385.             #endif
  386.             return 0;
  387.         }
  388.         return PointI[P];
  389.     }
  390. #endif
  391.  
  392. //==============================================================================
  393. //==============================================================================
  394. //==============================================================================
  395. stock GetPlayerPoint(playerid, r=0)
  396. {
  397.     new Float:x,Float:y, Float:z, X,Y,P,P2;
  398.     GetPlayerPos(playerid,x,y,z);
  399.     #if defined PointWorld
  400.     new WorldID=GetPlayerVirtualWorld(playerid);
  401.     #endif
  402.    
  403.     #if defined PointInterior
  404.     new InteriorID=GetPlayerInterior(playerid);
  405.     #endif
  406.     z=1000.0;
  407.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  408. //--------------------------
  409.     if(r == 2)
  410.     {
  411.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  412.         {
  413.             P=Point_Chunk[X][Y][OP];
  414.             #if defined PointWorld
  415.             if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  416.             #endif
  417.             #if defined PointInterior
  418.             if(InteriorID != PointI[P] || PointI[P]!=-1)continue;
  419.             #endif
  420.             if(IsPlayerInRangeOfPoint(playerid, PointR[P], PointX[P], PointY[P], PointZ[P]))return P;
  421.         }
  422.     }
  423.     else if(r == 1)
  424.     {
  425.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  426.         {
  427.             P=Point_Chunk[X][Y][OP];
  428.             #if defined PointWorld
  429.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  430.             #endif
  431.             #if defined PointInterior
  432.             if(InteriorID != PointI[P] && PointI[P]!=-1)continue;
  433.             #endif
  434.  
  435.             y=GetPlayerDistanceFromPoint(playerid, PointX[P], PointY[P], PointZ[P]);
  436.             if(y < z)
  437.             {
  438.                 z=y; P2=P;
  439.             }
  440.         }
  441.     }
  442.     else
  443.     {
  444.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  445.         {
  446.             P=Point_Chunk[X][Y][OP];
  447.             #if defined PointWorld
  448.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  449.             #endif
  450.             #if defined PointInterior
  451.             if(InteriorID != PointI[P] && PointI[P]!=-1)continue;
  452.             #endif
  453.             y=GetPlayerDistanceFromPoint(playerid, PointX[P], PointY[P], PointZ[P]);
  454.             if(y > PointR[P])continue;
  455.             if(y < z)
  456.             {
  457.                 z=y; P2=P;
  458.             }
  459.         }
  460.     }
  461.     return P2;
  462. }
  463.  
  464. stock GetPlayerMultiPoint(playerid, MP[], S)
  465. {
  466.     new Float:x,Float:y, Float:z, X,Y,P,K;
  467.     GetPlayerPos(playerid,x,y,z);
  468.     #if defined PointWorld
  469.     new WorldID=GetPlayerVirtualWorld(playerid);
  470.     #endif
  471.  
  472.     #if defined PointInterior
  473.     new InteriorID=GetPlayerInterior(playerid);
  474.     #endif
  475.     z=1000.0;
  476.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  477. //--------------------------
  478.     for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  479.     if(K < S)
  480.     {
  481.         P=Point_Chunk[X][Y][OP];
  482.         #if defined PointWorld
  483.         if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  484.         #endif
  485.         #if defined PointInterior
  486.         if(InteriorID != PointI[P] || PointI[P]!=-1)continue;
  487.         #endif
  488.        
  489.         if(IsPlayerInRangeOfPoint(playerid, PointR[P], PointX[P], PointY[P], PointZ[P]))
  490.         {
  491.             MP[K]=P; K++;
  492.         }
  493.     }
  494.     return K;
  495. }
  496. //==============================================================================
  497. stock GetVehiclePoint(vehicleid, r=0)
  498. {
  499.     new Float:x,Float:y, Float:z, X,Y,P,P2;
  500.     GetVehiclePos(vehicleid,x,y,z);
  501.     #if defined PointWorld
  502.     new WorldID=GetVehicleVirtualWorld(vehicleid);
  503.     #endif
  504.  
  505.     z=1000.0;
  506.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  507. //--------------------------
  508.     if(r == 2)
  509.     {
  510.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  511.         {
  512.             P=Point_Chunk[X][Y][OP];
  513.             #if defined PointWorld
  514.             if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  515.             #endif
  516.  
  517.             if(GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]) <= PointR[P])return P;
  518.         }
  519.     }
  520.     else if(r == 1)
  521.     {
  522.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  523.         {
  524.             P=Point_Chunk[X][Y][OP];
  525.             #if defined PointWorld
  526.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  527.             #endif
  528.  
  529.             y=GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]);
  530.             if(y < z)
  531.             {
  532.                 z=y; P2=P;
  533.             }
  534.         }
  535.     }
  536.     else
  537.     {
  538.         for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  539.         {
  540.             P=Point_Chunk[X][Y][OP];
  541.             #if defined PointWorld
  542.             if(WorldID != PointW[P] && PointW[P]!=-1)continue;
  543.             #endif
  544.  
  545.             y=GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]);
  546.             if(y > PointR[P])continue;
  547.             if(y < z)
  548.             {
  549.                 z=y; P2=P;
  550.             }
  551.         }
  552.     }
  553.     return P2;
  554. }
  555.  
  556. stock GetVehicleMultiPoint(vehicle, MP[], S)
  557. {
  558.     new Float:x,Float:y, Float:z, X,Y,P,K;
  559.     GetVehiclePos(vehicleid,x,y,z);
  560.     #if defined PointWorld
  561.     new WorldID=GetVehicleVirtualWorld(vehicleid);
  562.     #endif
  563.  
  564.     z=1000.0;
  565.     GetChunkPosXY(MAX_POINTS_REGION-MAX_POINTS_SETKA_DLINA, MAX_POINTS_SETKA_DLINA, x, y, X, Y);//  узнаём к какому квадрату относится точка
  566. //--------------------------
  567.     for(new OP=Point_PointsInChunk[X]{Y}-1; OP > -1; OP--)
  568.     if(K < S)
  569.     {
  570.         P=Point_Chunk[X][Y][OP];
  571.         #if defined PointWorld
  572.         if(WorldID != PointW[P] || PointW[P]!=-1)continue;
  573.         #endif
  574.  
  575.         if(GetVehicleDistanceFromPoint(vehicleid, PointX[P], PointY[P], PointZ[P]) <= PointR[P])
  576.         {
  577.             MP[K]=P; K++;
  578.         }
  579.     }
  580.     return K;
  581. }
  582.  
  583. #undef MAX_POINTS_TO_STREAM
  584. #undef MAX_POINTS_REGION
  585. #undef MAX_POINTS_SETKA_DLINA
  586. #undef MAX_POINTS_STORONA_DLINA
Add Comment
Please, Sign In to add comment