Advertisement
DraKiNs

[COD] Ver Caminho mais Curto PAWN

Jul 16th, 2011
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.22 KB | None | 0 0
  1. // Em Construção
  2. // Pare de olhar ou seus olhos pegaram fogo :s
  3.  
  4. #include <a_samp>
  5.  
  6. #define iMaxRoadPoint   120
  7. #define iMaxRoadings    018
  8.  
  9. new iRoads[iMaxRoadings][3] =
  10. {
  11.     {5, 84, 10},
  12.     {1, 2, 21},
  13.     {2, 1, 12},
  14.     {3, 4, 32},
  15.     {4, 0, 28},
  16.     {5, 8, 74},
  17.     {6, 10, 7},
  18.     {7, 0, 11},
  19.     {8, 22, 12},
  20.     {9, 44, 22},
  21.     {10, 11, 14},
  22.     {11, 11, 4},
  23.     {12, 13, 0},
  24.     {13, 1, 1},
  25.     {14, 8, 2},
  26.     {15, 9, 3},
  27.     {16, 15, 4},
  28.     {17, 20, 5}
  29. };
  30.  
  31. main()
  32. {
  33.     new BestRoad = GetRoadPoints(5, 6, 1);
  34.     printf("O ponto mais próximo de 5, 6, 1 é %d %d %d", iRoads[BestRoad][0],iRoads[BestRoad][1],iRoads[BestRoad][2]);
  35. }
  36.  
  37.  
  38. GetRoadPoints(xRoad, yRoad,zRoad)
  39. {
  40.     new
  41.         RoadPoint = 0,
  42.         RoadLow = iMaxRoadPoint;
  43.  
  44.     for(new i = 0; i != iMaxRoadings; i++) {
  45.         new
  46.             RoadValue =  floatround(floatsqroot(floatpower(floatsub(iRoads[i][0], xRoad), 2) + floatpower(floatsub( iRoads[i][1], yRoad), 2) + floatpower(floatsub( iRoads[i][2], zRoad), 2)));
  47.  
  48.         if(RoadValue < RoadLow) {
  49.             RoadLow = RoadValue;
  50.             RoadPoint = i;
  51.         }
  52.     }
  53.     return RoadPoint;
  54. }
  55.  
  56.  
  57. // Por Bruno da Silva
  58. // www.ips-team.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement