Advertisement
Guest User

Untitled

a guest
Mar 20th, 2014
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <streamer>
  4.  
  5. #define dred 0xA00000FF
  6.  
  7. forward superman(playerid);
  8. forward DestroyMe(objectid);
  9. forward Jav(playerid);
  10. forward Float:SetPlayerToFacePos(playerid, Float:X, Float:Y);
  11. forward GetClosestPlayer(p1);
  12. forward Float:GetDistanceBetweenPlayers(p1, p2);
  13.  
  14. new
  15. bool:flying[MAX_PLAYERS],
  16. Javelin[MAX_PLAYERS][2],
  17. Float:JavPos[MAX_PLAYERS][3];
  18.  
  19. public OnFilterScriptInit()
  20. {
  21. print("\n=======================================");
  22. print("\n");
  23. print(" SuperMan FS Loaded. ");
  24. print("\n");
  25. print("=========================================");
  26. return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31. print("________________________________________");
  32. return 1;
  33. }
  34. stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
  35. {
  36. a1 -= a2;
  37. if((a1 < range) && (a1 > -range)) return true;
  38.  
  39. return false;
  40. }
  41. CMD:superman(playerid,params[])
  42. {
  43.  
  44. if((flying[playerid] = !flying[playerid]))
  45. {
  46. new Float:x, Float:y, Float:z;
  47. GetPlayerPos(playerid, x, y, z);
  48. SetPlayerHealth(playerid, 1000000000.0);
  49. SetPlayerArmour(playerid, 1000000000.0);
  50. SetTimerEx("superman", 100, 0, "d", playerid);
  51. SetTimerEx("DestroyMe", 500, 0, "d", CreateDynamicObject(2780, x, y, z - 3.0, 0.0, 0.0, 0.0));
  52. }
  53. SetPlayerHealth(playerid, 100.0);
  54. SetPlayerArmour(playerid, 100.0);
  55. return 1;
  56.  
  57. }
  58.  
  59.  
  60. stock IsPlayerFacingPlayer(playerid, targetid, Float:dOffset)
  61. {
  62. new
  63. Float:pX,
  64. Float:pY,
  65. Float:pZ,
  66. Float:pA,
  67. Float:X,
  68. Float:Y,
  69. Float:Z,
  70. Float:ang;
  71.  
  72. if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid)) return 0;
  73.  
  74. GetPlayerPos(targetid, pX, pY, pZ);
  75. GetPlayerPos(playerid, X, Y, Z);
  76. GetPlayerFacingAngle(playerid, pA);
  77.  
  78. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  79. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  80. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  81.  
  82. return AngleInRangeOfAngle(-ang, pA, dOffset);
  83. }
  84. public superman(playerid)
  85. {
  86. if(!IsPlayerConnected(playerid))
  87. return flying[playerid] = false;
  88.  
  89. if(flying[playerid])
  90. {
  91. if(!IsPlayerInAnyVehicle(playerid))
  92. {
  93. new
  94. i,
  95. keys,
  96. ud,
  97. lr,
  98. Float:x[2],
  99. Float:y[2],
  100. Float:z,
  101. Float:a;
  102.  
  103. GetPlayerKeys(playerid, keys, ud, lr);
  104. GetPlayerVelocity(playerid, x[0], y[0], z);
  105.  
  106. if(!GetPlayerWeapon(playerid))
  107. {
  108. if((keys & KEY_FIRE) == (KEY_FIRE))
  109. {
  110. i = 0;
  111. while(i < MAX_PLAYERS)
  112. {
  113. if(i != playerid)
  114. {
  115. GetPlayerPos(i, x[0], y[0], z);
  116. if(IsPlayerInRangeOfPoint(playerid, 3.0, x[0], y[0], z))
  117. if(IsPlayerFacingPlayer(playerid, i, 15.0))
  118. SetPlayerVelocity(i, floatsin(-a, degrees), floatcos(-a, degrees), 0.05);
  119. }
  120. ++i;
  121. }
  122. }
  123.  
  124. if((keys & 136) == (136))
  125. Jav(playerid);
  126.  
  127. }
  128.  
  129. if(ud == KEY_UP)
  130. {
  131. GetPlayerCameraPos(playerid, x[0], y[0], z);
  132. GetPlayerCameraFrontVector(playerid, x[1], y[1], z);
  133.  
  134. a = SetPlayerToFacePos(playerid, x[0] + x[1], y[0] + y[1]);
  135.  
  136. ApplyAnimation(playerid, "PARACHUTE", "FALL_SkyDive_Accel", 4.1, 0, 0, 0, 0, 0);
  137. SetPlayerVelocity(playerid, x[1], y[1], z);
  138.  
  139. i = 0;
  140. while(i < MAX_PLAYERS)
  141. {
  142. if(i != playerid)
  143. {
  144. GetPlayerPos(i, x[0], y[0], z);
  145. if(IsPlayerInRangeOfPoint(playerid, 10.0, x[0], y[0], z))
  146. if(IsPlayerInAnyVehicle(i))
  147. {
  148. SetVehicleHealth(GetPlayerVehicleID(i), 0.0);
  149. CreateExplosion(x[0], y[0], z, 7, 5.0);
  150. }
  151. }
  152.  
  153. ++i;
  154. }
  155. }
  156. else
  157. SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
  158. }
  159.  
  160. SetTimerEx("superman", 100, 0, "d", playerid);
  161. }
  162.  
  163. return 0;
  164. }
  165.  
  166. public DestroyMe(objectid)
  167. {
  168. return DestroyObject(objectid);
  169. }
  170.  
  171. public Jav(playerid)
  172. {
  173. if(!Javelin[playerid][1])
  174. {
  175. new
  176. target = GetClosestPlayer(playerid);
  177.  
  178. if(target != -1)
  179. {
  180. GetPlayerPos(target, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
  181. if(IsPlayerInRangeOfPoint(playerid, 500.0, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]))
  182. {
  183. new Float:a;
  184. GetPlayerPos(playerid, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
  185. GetPlayerFacingAngle(playerid, a);
  186.  
  187. Javelin[playerid][0] = CreateDynamicObject(354, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2], 0.0, 90.0, 0.0);
  188. MoveObject(Javelin[playerid][0], JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2] + 100.0, 45.0);
  189.  
  190. GetPlayerPos(target, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
  191.  
  192. Javelin[playerid][1] = 1;
  193. }
  194. }
  195. }
  196.  
  197. return 0;
  198. }
  199.  
  200. public Float:SetPlayerToFacePos(playerid, Float:X, Float:Y)
  201. {
  202. new
  203. Float:pX,
  204. Float:pY,
  205. Float:pZ,
  206. Float:ang;
  207.  
  208. if(!IsPlayerConnected(playerid)) return 0.0;
  209.  
  210. GetPlayerPos(playerid, pX, pY, pZ);
  211.  
  212. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  213. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  214. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  215.  
  216. if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
  217. else ang = (floatabs(ang) - 180.0);
  218.  
  219. ang += 180.0;
  220.  
  221. SetPlayerFacingAngle(playerid, ang);
  222.  
  223. return ang;
  224. }
  225. public GetClosestPlayer(p1)
  226. {
  227. new
  228. x,
  229. Float:dis,
  230. Float:dis2,
  231. player;
  232.  
  233. player = -1;
  234. dis = 99999.99;
  235.  
  236. for (x=0;x<MAX_PLAYERS;x++)
  237. if(IsPlayerConnected(x))
  238. if(x != p1)
  239. {
  240. dis2 = GetDistanceBetweenPlayers(x,p1);
  241. if(dis2 < dis && dis2 != -1.00)
  242. {
  243. dis = dis2;
  244. player = x;
  245. }
  246. }
  247.  
  248. return player;
  249. }
  250. public Float:GetDistanceBetweenPlayers(p1, p2)
  251. {
  252. new
  253. Float:x1,
  254. Float:y1,
  255. Float:z1,
  256. Float:x2,
  257. Float:y2,
  258. Float:z2;
  259.  
  260. if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  261. return -1.00;
  262.  
  263. GetPlayerPos(p1,x1,y1,z1);
  264. GetPlayerPos(p2,x2,y2,z2);
  265.  
  266. return floatsqroot(
  267. floatpower(floatabs(floatsub(x2,x1)), 2)
  268. + floatpower(floatabs(floatsub(y2,y1)), 2)
  269. + floatpower(floatabs(floatsub(z2,z1)), 2));
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement