Advertisement
Faisal_khan

Moving Ship

Apr 8th, 2012
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.97 KB | None | 0 0
  1. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*\
  2. ||                                                                                            ||
  3. ||                      Created 8th April 2012 By Faisal Khan (faisal3325@gmail.com).                                 ||
  4. ||      WARNING: Do NOT Claim This As Your Own. Do NOT Re-Release This Without Permission.    ||
  5. ||                                  DO NOT SELL THIS SCRIPT!                                  ||
  6. ||                                        Credits: Faisal_khan, Kye and Ahemad_khan                                                ||
  7. \*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  8.  
  9. //=================================INCLUDES=================================//
  10. #include <a_samp>
  11. //=================================DEFINES==================================//
  12. #define FILTERSCRIPT
  13. #define NUM_SHIP_ROUTE_POINTS   25
  14. #define SHIP_MOVE_SPEED         10.0
  15. #define SHIP_DRAW_DISTANCE      300.0
  16. #define NUM_SHIP_ATTACHMENTS    10
  17. #define SHIP_HULL_ID            9585
  18. //--------------------------------------------------------------------------//
  19. new gShipsAttachments[NUM_SHIP_ROUTE_POINTS];
  20. new gMainShipObjectId;
  21. new gShipCurrentPoint = 1;
  22. new Float:gShipHullOrigin[3] =
  23. { -2409.8438, 1544.9453, 7.0000 }; // so we can convert world space to model space for attachment positions
  24.  
  25. new gShipAttachmentModelIds[NUM_SHIP_ATTACHMENTS] = {
  26. 9586, // Ship main platform
  27. 9761, // Ship rails
  28. 9584, // Bridge exterior
  29. 9698, // Bridge interior
  30. 9821, // Bridge interior doors
  31. 9818, // Bridge radio desk
  32. 9819, // Captain's desk
  33. 9822, // Captain's seat
  34. 9820, // Bridge ducts and lights
  35. 9590  // Cargo bay area
  36. };
  37.  
  38. new Float:gShipAttachmentPos[NUM_SHIP_ATTACHMENTS][3] = {
  39. // these are world space positions used on the original cargo ship in the game
  40. // they will be converted to model space before attaching
  41. {-2412.1250, 1544.9453, 17.0469},
  42. {-2411.3906, 1544.9453, 27.0781},
  43. {-2485.0781, 1544.9453, 26.1953},
  44. {-2473.5859, 1543.7734, 29.0781},
  45. {-2474.3594, 1547.2422, 24.7500},
  46. {-2470.2656, 1544.9609, 33.8672},
  47. {-2470.4531, 1551.1172, 33.1406},
  48. {-2470.9375, 1550.7500, 32.9063},
  49. {-2474.6250, 1545.0859, 33.0625},
  50. {-2403.5078, 1544.9453, 8.7188}
  51. };
  52. //This is our ship route points you can modify this as to your wish
  53. new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][6] = {
  54. {-1982.57, 2052.56, 0.00,   0.00, 0.00, 144.84},
  55. {-2178.63, 2103.67, 0.00,   0.00, 0.00, 189.24},
  56. {-2366.64, 2020.28, 0.00,   0.00, 0.00, 215.22},
  57. {-2539.06, 1892.52, 0.00,   0.00, 0.00, 215.22},
  58. {-2722.79, 1787.85, 0.00,   0.00, 0.00, 205.62},
  59. {-2918.51, 1729.60, 0.00,   0.00, 0.00, 190.50},
  60. {-3124.70, 1758.03, 0.00,   0.00, 0.00, 156.36},
  61. {-3316.51, 1850.08, 0.00,   0.00, 0.00, 153.36},
  62. {-3541.12, 1977.99, 0.00,   0.00, 0.00, 145.74},
  63. {-3772.54, 2140.70, 0.00,   0.00, 0.00, 144.96},
  64. {-4078.78, 2272.93, 0.00,   0.00, 0.00, 167.52},
  65. {-4382.22, 2222.52, 0.00,   0.36, 0.06, 206.70},
  66. {-4578.11, 2013.70, 0.00,   0.36, 0.54, 244.80},
  67. {-4603.54, 1718.89, 0.00,   1.92, -0.36, 283.26},
  68. {-4463.49, 1504.50, 0.00,   0.92, -0.36, 316.32},
  69. {-4228.00, 1380.52, 0.00,   0.92, -0.36, 342.54},
  70. {-3950.14, 1346.96, 0.00,   0.02, -0.06, 359.64},
  71. {-3646.69, 1344.57, 0.00,   0.02, -0.06, 359.64},
  72. {-3350.01, 1410.39, 0.00,   0.02, -0.06, 384.48},
  73. {-2854.63, 1651.56, 0.00,   0.02, -0.06, 378.54},
  74. {-2590.84, 1667.61, 0.00,   0.02, -0.06, 356.28},
  75. {-2345.84, 1633.19, 0.00,   0.02, -0.06, 350.28},
  76. {-2106.14, 1639.23, 0.00,   0.02, -0.06, 378.36},
  77. {-1943.63, 1743.98, 0.00,   0.02, -0.06, 411.42},
  78. {-1891.39, 1907.57, 0.00,   0.02, -0.06, 457.14}
  79. };
  80.  
  81. //==================================FORWARDS============================================//
  82. forward StartMovingTimer();
  83. //=======================================================================================//
  84. public OnFilterScriptInit()
  85. {
  86.     print("\n--------------------------------");
  87.     print("Moving Ship By Faisal_khan");
  88.     print("--------------------------------\n");
  89.  
  90.     gMainShipObjectId = CreateObject(SHIP_HULL_ID, gShipRoutePoints[0][0], gShipRoutePoints[0][1], gShipRoutePoints[0][2],
  91.                                     gShipRoutePoints[0][3], gShipRoutePoints[0][4], gShipRoutePoints[0][5], SHIP_DRAW_DISTANCE);
  92.  
  93.     new x=0;
  94.     while(x != NUM_SHIP_ATTACHMENTS) {
  95.         gShipsAttachments[x] = CreateObject(gShipAttachmentModelIds[x], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  96.         AttachObjectToObject(gShipsAttachments[x], gMainShipObjectId,
  97.                     gShipAttachmentPos[x][0] - gShipHullOrigin[0],
  98.                     gShipAttachmentPos[x][1] - gShipHullOrigin[1],
  99.                     gShipAttachmentPos[x][2] - gShipHullOrigin[2],
  100.                     0.0, 0.0, 0.0);
  101.         x++;
  102.     }
  103.     SetTimer("StartMovingTimer",30*1000,0); // pause at route 0 for 30 seconds
  104.     return 1;
  105. }
  106.  
  107. public StartMovingTimer()
  108. {
  109.     MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  110.                                gShipRoutePoints[gShipCurrentPoint][1],
  111.                                gShipRoutePoints[gShipCurrentPoint][2],
  112.                                SHIP_MOVE_SPEED / 3.0,
  113.                                gShipRoutePoints[gShipCurrentPoint][3],
  114.                                gShipRoutePoints[gShipCurrentPoint][4],
  115.                                gShipRoutePoints[gShipCurrentPoint][5]);
  116. }
  117.  
  118. public OnObjectMoved(objectid)
  119. {
  120.     if(objectid != gMainShipObjectId) return 0;
  121.  
  122.     if(gShipCurrentPoint > 0 && !(gShipCurrentPoint % 5)) {
  123.         // play some seagulls audio every 5 points
  124.         PlaySoundForPlayersInRange(6200, 200.0, gShipRoutePoints[gShipCurrentPoint][0],
  125.                         gShipRoutePoints[gShipCurrentPoint][1],
  126.                         gShipRoutePoints[gShipCurrentPoint][2]);
  127.     }
  128.  
  129.     gShipCurrentPoint++;
  130.  
  131.     if(gShipCurrentPoint == NUM_SHIP_ROUTE_POINTS) {
  132.         gShipCurrentPoint = 0;
  133.  
  134.         MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  135.                                gShipRoutePoints[gShipCurrentPoint][1],
  136.                                gShipRoutePoints[gShipCurrentPoint][2],
  137.                                SHIP_MOVE_SPEED / 2.0,
  138.                                gShipRoutePoints[gShipCurrentPoint][3],
  139.                                gShipRoutePoints[gShipCurrentPoint][4],
  140.                                gShipRoutePoints[gShipCurrentPoint][5]);
  141.         return 1;
  142.     }
  143.  
  144.     if(gShipCurrentPoint == 1) {
  145.         SetTimer("StartMovingTimer",30*1000,0);
  146.         return 1;
  147.     }
  148.  
  149.     MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  150.                                gShipRoutePoints[gShipCurrentPoint][1],
  151.                                gShipRoutePoints[gShipCurrentPoint][2],
  152.                                SHIP_MOVE_SPEED,
  153.                                gShipRoutePoints[gShipCurrentPoint][3],
  154.                                gShipRoutePoints[gShipCurrentPoint][4],
  155.                                gShipRoutePoints[gShipCurrentPoint][5]);
  156.  
  157.     return 1;
  158. }
  159.  
  160. public OnPlayerCommandText(playerid, cmdtext[])
  161. {
  162.     if(!strcmp(cmdtext, "/tele", true))
  163.     {
  164.         SetPlayerPos(playerid,-2100, 2052.56, 0);
  165.         return 1;
  166.     }
  167.     return 0;
  168. }
  169. //=================================STOCK======================================//
  170. stock PlaySoundForPlayersInRange(soundid, Float:range, Float:x, Float:y, Float:z)
  171. {
  172.     for(new i=0; i<MAX_PLAYERS; i++)
  173.     {
  174.         if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,range,x,y,z))
  175.         {
  176.             PlayerPlaySound(i, soundid, x, y, z);
  177.         }
  178.     }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement