Advertisement
Guest User

Untitled

a guest
Feb 19th, 2011
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.72 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define SHIP_OBJECTS 14
  4.  
  5. new object[SHIP_OBJECTS];
  6. new Float:rotangle, Float:summrot;
  7. new boat, player_in_boat = -1;
  8. new refresh_ship;
  9. new Float:wasX, Float:wasY;
  10. new Float:wasAngle;
  11. new camera;
  12. new Float:PI = 3.1415926535897932384626433832795;
  13.  
  14. forward RotateAll();
  15. forward RotateShipPart(objectID);
  16. forward RefreshShip();
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. print("\n--------------------------------------");
  21. print(" Big ship by Ponchik");
  22. print("--------------------------------------\n");
  23.  
  24. //here you can change coordinates of ship... If you can
  25. new Float:modx, Float:mody, Float:modz;
  26. modx = -2200.45574;
  27. mody = 2585.92434;
  28. modz = 0;
  29.  
  30. //do not edit coordinates here/delete/modify objects... just recommend to you
  31. object[0] = CreateObject(10771, -1357.70-modx, 501.30-mody, 5.45-modz, 0.00000, 0.000000, 0.000000); //ship
  32. object[1] = CreateObject(10772, -1356.35-modx, 501.12-mody, 17.27-modz, 0.00000, 0.000000, 0.000000); //white thing on floor (oh my english...)
  33. object[2] = CreateObject(11146, -1366.69-modx, 501.85-mody, 12.29-modz, 0.00000, 0.000000, 0.000000); //ship interior
  34. object[3] = CreateObject(11145, -1420.58-modx, 501.30-mody, 4.26-modz, 0.00000, 0.000000, 0.000000); //ship interior part 2
  35. object[4] = CreateObject(11148, -1366.69-modx, 501.30-mody, 12.88-modz, 0.00000, 0.000000, 0.000000); //some pipes
  36. object[5] = CreateObject(11147, -1418.41-modx, 501.30-mody, 5.08-modz, 0.00000, 0.000000, 0.000000); //again some pipes
  37. object[6] = CreateObject(11149, -1363.77-modx, 496.09-mody, 11.98-modz, 0.00000, 0.000000, 0.000000); //ship interior part 3
  38. object[7] = CreateObject(11237, -1354.42-modx, 493.75-mody, 38.68-modz, 0.00000, 0.000000, 0.000000); //antenas
  39. object[8] = CreateObject(10770, -1354.47-modx, 493.75-mody, 38.68-modz, 0.00000, 0.000000, 0.000000); //base for antenas
  40. object[9] = CreateObject(3885, -1324.33-modx, 493.81-mody, 21.02-modz, 0.00000, 0.000000, 0.000000); //base for rockets
  41. object[10] = CreateObject(3884, -1324.33-modx, 493.81-mody, 21.05-modz, 0.00000, 0.000000, 0.000000); //rockets
  42. object[11] = CreateObject(3885, -1394.80-modx, 493.40-mody, 18.01-modz, 0.00000, 0.000000, 0.000000); //base for rockets 2
  43. object[12] = CreateObject(3884, -1394.80-modx, 493.40-mody, 18.05-modz, 0.00000, 0.000000, 0.000000); //rockets 2
  44. object[13] = CreateObject(11374, -1363.77-modx, 496.09-mody, 11.98-modz, 0.00000, 0.000000, 0.000000); //bended pipes
  45.  
  46. return 1;
  47. }
  48.  
  49. public OnFilterScriptExit()
  50. {
  51. for(new a; a<SHIP_OBJECTS; a++) {
  52. DestroyObject(object[a]);
  53. }
  54.  
  55. DestroyVehicle(boat);
  56. KillTimer(refresh_ship);
  57. if(player_in_boat != -1) {
  58. SpawnPlayer(player_in_boat);
  59. SetCameraBehindPlayer(player_in_boat);
  60. }
  61.  
  62. return 1;
  63. }
  64.  
  65. public OnPlayerCommandText(playerid, cmdtext[])
  66. {
  67. if(strcmp(cmdtext, "/shiphelp", true, 9) == 0)
  68. {
  69. SendClientMessage(playerid, 0x00FF00FF, "Big ship by {F57E2F}Ponchik {00FF00}(btw hello to {13A61E}antichat {00FF00}team)");
  70. SendClientMessage(playerid, 0x00FF00FF, "Use {FFCC00}/goinship {00FF00}to control ship");
  71. SendClientMessage(playerid, 0x00FF00FF, "Use {FFCC00}/shipcam1 /shipcam2 /shipcam3 /shipcam4{00FF00} to change camera");
  72. SendClientMessage(playerid, 0x00FF00FF, "Press {FFCC00}F{00FF00} to exit from ship");
  73. return 1;
  74. }
  75.  
  76. if(strcmp(cmdtext, "/goinship", true, 9) == 0 && IsPlayerAdmin(playerid)) //only for admin
  77. {
  78. if(player_in_boat != -1) {
  79. SendClientMessage(playerid, 0xFF0000FF, "Other player controling ship");
  80. printf("player_in_boat = %i",player_in_boat);
  81. return 1;
  82. }
  83. new Float:RotX,Float:RotY,Float:RotZ;
  84. GetObjectRot(object[0], RotX, RotY, RotZ);
  85.  
  86. boat = CreateVehicle(484, 7000.0, 7000.0, 0, (RotZ-90), 1, 1, 60); //here you can change boat for more cool control, if you will use car - make hard surface
  87. PutPlayerInVehicle(playerid, boat, 0);
  88. player_in_boat = playerid;
  89. refresh_ship = SetTimer("RefreshShip", 100, true); //here you can change refresh time, but i dont think it will help
  90.  
  91. camera = 1;
  92. return 1;
  93. }
  94.  
  95. if(strcmp(cmdtext, "/shipcam1", true, 9) == 0 && player_in_boat == playerid && IsPlayerAdmin(playerid))
  96. {
  97. camera = 1;
  98. return 1;
  99. }
  100.  
  101. if(strcmp(cmdtext, "/shipcam2", true, 9) == 0 && player_in_boat == playerid && IsPlayerAdmin(playerid))
  102. {
  103. camera = 2;
  104. return 1;
  105. }
  106.  
  107. if(strcmp(cmdtext, "/shipcam3", true, 9) == 0 && player_in_boat == playerid && IsPlayerAdmin(playerid))
  108. {
  109. camera = 3;
  110. return 1;
  111. }
  112.  
  113. if(strcmp(cmdtext, "/shipcam4", true, 9) == 0 && player_in_boat == playerid && IsPlayerAdmin(playerid))
  114. {
  115. camera = 4;
  116. return 1;
  117. }
  118.  
  119. return 0;
  120. }
  121.  
  122. public OnPlayerExitVehicle(playerid, vehicleid)
  123. {
  124. if(vehicleid == boat) {
  125. DestroyVehicle(boat);
  126. boat = 0;
  127. player_in_boat = -1;
  128. KillTimer(refresh_ship);
  129. new Float:x, Float:y, Float:z;
  130. GetObjectPos(object[0], x, y, z);
  131. SetPlayerPos(playerid,x, y, z+15);
  132. SetCameraBehindPlayer(playerid);
  133. }
  134. return 1;
  135. }
  136.  
  137. public OnPlayerDeath(playerid, killerid, reason)
  138. {
  139. if(player_in_boat == playerid) {
  140. DestroyVehicle(boat);
  141. boat = 0;
  142. player_in_boat = -1;
  143. KillTimer(refresh_ship);
  144. new Float:x, Float:y, Float:z;
  145. GetObjectPos(object[0], x, y, z);
  146. SetPlayerPos(playerid,x, y, z+15);
  147. SetCameraBehindPlayer(playerid);
  148. }
  149. return 1;
  150. }
  151.  
  152. public OnPlayerDisconnect(playerid, reason)
  153. {
  154. if(player_in_boat == playerid) {
  155. player_in_boat = -1;
  156. DestroyVehicle(boat);
  157. boat = 0;
  158. KillTimer(refresh_ship);
  159. }
  160. return 1;
  161. }
  162.  
  163. public RotateAll() {
  164. for(new a; a<SHIP_OBJECTS; a++) {
  165. RotateShipPart(object[a]);
  166. }
  167. }
  168.  
  169. public RotateShipPart(objectID) { //let's do some math
  170. new Float:new_BX, Float:new_BY, Float:aradian, Float:x1, Float:y1, Float:x_v_staroi, Float:y_v_staroi, Float:ugol;
  171.  
  172. new Float:start_position_AX, Float:start_position_AY, Float:z_tmp;
  173. GetObjectPos(object[0], start_position_AX, start_position_AY, z_tmp);
  174.  
  175. new Float:start_position_BX, Float:start_position_BY, Float:z;
  176. GetObjectPos(objectID, start_position_BX, start_position_BY, z);
  177.  
  178. ugol = rotangle;
  179.  
  180. new_BX = start_position_BX-start_position_AX;
  181. new_BY = start_position_BY-start_position_AY;
  182.  
  183. aradian = ugol*(PI/180);
  184. x1 = new_BX*floatcos(aradian)+new_BY*floatsin(aradian);
  185. y1 = -new_BX*floatsin(aradian)+new_BY*floatcos(aradian);
  186.  
  187. x_v_staroi = x1+start_position_AX;
  188. y_v_staroi = y1+start_position_AY;
  189.  
  190. SetObjectPos(objectID, x_v_staroi, y_v_staroi, z);
  191. SetObjectRot(objectID, 0, 0, summrot);
  192. }
  193.  
  194. public RefreshShip() {
  195. new Float:vehx, Float:vehy, Float:vehz;
  196. GetVehiclePos(boat, vehx, vehy, vehz);
  197. if(!wasX || !wasY) {
  198. wasX = vehx;
  199. wasY = vehy;
  200. }
  201.  
  202. if(!IsPlayerInRangeOfPoint(player_in_boat, 3000.0, 7000.0, 7000.0, 0)) { // If player go to land or out of world, if you make hard surface - change radius
  203. wasX = 7000.0;
  204. wasY = 7000.0;
  205. SetVehiclePos(boat, 7000.0, 7000.0, 0);
  206. }
  207.  
  208. new Float:boat_angle;
  209. GetVehicleZAngle(boat, boat_angle);
  210.  
  211. boat_angle = boat_angle-270;
  212. summrot = boat_angle;
  213. rotangle = wasAngle-boat_angle;
  214. wasAngle = boat_angle;
  215.  
  216. RotateAll();
  217.  
  218. new Float:Velocity[3];
  219. GetVehicleVelocity(boat, Velocity[0], Velocity[1], Velocity[2]);
  220. if(Velocity[0]<0) Velocity[0] = 0-Velocity[0];
  221. if(Velocity[1]<0) Velocity[1] = 0-Velocity[1];
  222. Velocity[2] = Velocity[0]+Velocity[1];
  223.  
  224. for(new a; a<SHIP_OBJECTS; a++) {
  225. new Float:x, Float:y, Float:z;
  226. GetObjectPos(object[a], x, y, z);
  227. MoveObject(object[a], x-(wasX-vehx), y-(wasY-vehy), z, Velocity[2]*30); //make it faster or slower for more smoothness
  228. }
  229.  
  230. wasX = vehx;
  231. wasY = vehy;
  232.  
  233. //change camera position here
  234. new Float:AX, Float:AY, Float:AZ;
  235. new Float:BX, Float:BY, Float:BZ;
  236. new Float:CamPosX, Float:CamPosY, Float:CamPosZ;
  237. new Float:CamPointX, Float:CamPointY, Float:CamPointZ;
  238.  
  239. GetObjectPos(object[0], AX, AY, AZ);
  240. GetObjectPos(object[3], BX, BY, BZ);
  241.  
  242. if(camera == 1) {
  243. CamPointX = AX;
  244. CamPointY = AY;
  245.  
  246. CamPosX = BX-AX;
  247. CamPosY = BY-AY;
  248. CamPosX = CamPosX*1.3;
  249. CamPosY = CamPosY*1.3;
  250. CamPosX = CamPosX+AX;
  251. CamPosY = CamPosY+AY;
  252.  
  253. CamPosZ = 50;
  254. CamPointZ = 4;
  255. }else if(camera == 2) {
  256. CamPointX = AX-BX;
  257. CamPointY = AY-BY;
  258. CamPointX = CamPointX*0.1;
  259. CamPointY = CamPointY*0.1;
  260. CamPointX = CamPointX+BX;
  261. CamPointY = CamPointY+BY;
  262.  
  263. CamPosX = BX-AX;
  264. CamPosY = BY-AY;
  265. CamPosX = CamPosX*2.3;
  266. CamPosY = CamPosY*2.3;
  267. CamPosX = CamPosX+AX;
  268. CamPosY = CamPosY+AY;
  269.  
  270. CamPosZ = 80;
  271. CamPointZ = 1;
  272. }else if(camera == 3) {
  273. CamPointX = AX-BX;
  274. CamPointY = AY-BY;
  275. CamPointX = CamPointX*1.3;
  276. CamPointY = CamPointY*1.3;
  277. CamPointX = CamPointX+BX;
  278. CamPointY = CamPointY+BY;
  279.  
  280. CamPosX = BX-AX;
  281. CamPosY = BY-AY;
  282. CamPosX = CamPosX*0.01;
  283. CamPosY = CamPosY*0.01;
  284. CamPosX = CamPosX+AX;
  285. CamPosY = CamPosY+AY;
  286.  
  287. CamPosZ = 80;
  288. CamPointZ = 1;
  289. }else if(camera == 4) {
  290. CamPointX = AX-BX;
  291. CamPointY = AY-BY;
  292. CamPointX = CamPointX*2.4;
  293. CamPointY = CamPointY*2.4;
  294. CamPointX = CamPointX+BX;
  295. CamPointY = CamPointY+BY;
  296.  
  297. CamPosX = BX-AX;
  298. CamPosY = BY-AY;
  299. CamPosX = CamPosX*(-1);
  300. CamPosY = CamPosY*(-1);
  301. CamPosX = CamPosX+AX;
  302. CamPosY = CamPosY+AY;
  303.  
  304. CamPosZ = 80;
  305. CamPointZ = 1;
  306. }
  307.  
  308. SetPlayerCameraPos(player_in_boat, CamPosX, CamPosY, CamPosZ);
  309. SetPlayerCameraLookAt(player_in_boat, CamPointX, CamPointY, CamPointZ);
  310. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement