Guest User

SpiderPork

a guest
Mar 24th, 2009
39,734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #if defined FILTERSCRIPT
  6.  
  7. #define RED 0xFF0000FF
  8.  
  9. new Rocket[MAX_PLAYERS];
  10. new RocketFiring[MAX_PLAYERS];
  11. new IsInRustler[MAX_PLAYERS];
  12.  
  13. stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  14. {
  15. new Float:oldposx, Float:oldposy, Float:oldposz;
  16. new Float:tempposx, Float:tempposy, Float:tempposz;
  17. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  18. tempposx = (oldposx -x);
  19. tempposy = (oldposy -y);
  20. tempposz = (oldposz -z);
  21. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  22. {
  23. return 1;
  24. }
  25. return 0;
  26. }
  27.  
  28. stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  29. {
  30. new Float:a;
  31. GetPlayerPos(playerid, x, y, a);
  32. if (IsPlayerInAnyVehicle(playerid))
  33. GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  34. else
  35. GetPlayerFacingAngle(playerid, a);
  36. x += (distance * floatsin(-a, degrees));
  37. y += (distance * floatcos(-a, degrees));
  38. return a;
  39. }
  40.  
  41. public OnFilterScriptInit()
  42. {
  43. return 1;
  44. }
  45.  
  46. public OnFilterScriptExit()
  47. {
  48. return 1;
  49. }
  50.  
  51. #else
  52.  
  53. main()
  54. {
  55. print("\n--------------------------------------");
  56. print("Fire rockets with a rustler ");
  57. print(" by SpiderPork ");
  58. print("--------------------------------------\n");
  59. }
  60.  
  61. #endif
  62.  
  63. public OnPlayerCommandText(playerid, cmdtext[])
  64. {
  65. if (strcmp("/fire", cmdtext, true, 10) == 0)
  66. {
  67. if(RocketFiring[playerid] == 0)
  68. {
  69. if(IsInRustler[playerid] == 1)
  70. {
  71. new Float:X, Float:Y, Float:Z, Float:Angle, Float:X2, Float:Y2, vehicleid;
  72. vehicleid = GetPlayerVehicleID(playerid);
  73. GetPlayerPos(playerid, X, Y, Z);
  74. GetVehicleZAngle(vehicleid, Angle);
  75. Rocket[playerid] = CreateObject(3790, X, Y, Z-3.0, 0, 0, Angle+90);
  76. GetXYInFrontOfPlayer(playerid, X2, Y2, 100.0);
  77. MoveObject(Rocket[playerid], X2, Y2, Z, 100.0);
  78. RocketFiring[playerid] = 1;
  79. }
  80. }
  81. return 1;
  82. }
  83. return 0;
  84. }
  85.  
  86. public OnPlayerEnterVehicle(playerid, vehicleid)
  87. {
  88. if(GetVehicleModel(vehicleid) == 476)
  89. {
  90. IsInRustler[playerid] = 1;
  91. }
  92. return 1;
  93. }
  94.  
  95. public OnPlayerExitVehicle(playerid, vehicleid)
  96. {
  97. if(GetVehicleModel(vehicleid) == 476)
  98. {
  99. IsInRustler[playerid] = 0;
  100. }
  101. return 1;
  102. }
  103.  
  104. public OnObjectMoved(objectid)
  105. {
  106. new playerid;
  107. if(objectid == Rocket[playerid])
  108. {
  109. new Float:X, Float:Y, Float:Z;
  110. GetObjectPos(Rocket[playerid], X, Y, Z);
  111. DestroyObject(Rocket[playerid]);
  112. CreateExplosion(X, Y, Z, 6, 10.0);
  113. RocketFiring[playerid] = 0;
  114. }
  115. return 1;
  116. }
  117.  
  118. public OnPlayerConnect(playerid)
  119. {
  120. RocketFiring[playerid] = 0;
  121. IsInRustler[playerid] = 0;
  122. return 1;
  123. }
  124.  
  125. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  126. {
  127. if(newkeys == KEY_FIRE)
  128. {
  129. if(RocketFiring[playerid] == 0)
  130. {
  131. if(IsInRustler[playerid] == 1)
  132. {
  133. new Float:X, Float:Y, Float:Z, Float:Angle, Float:X2, Float:Y2, vehicleid;
  134. vehicleid = GetPlayerVehicleID(playerid);
  135. GetPlayerPos(playerid, X, Y, Z);
  136. GetVehicleZAngle(vehicleid, Angle);
  137. Rocket[playerid] = CreateObject(3790, X, Y, Z-3.0, 0, 0, Angle+90);
  138. GetXYInFrontOfPlayer(playerid, X2, Y2, 100.0);
  139. MoveObject(Rocket[playerid], X2, Y2, Z, 100.0);
  140. RocketFiring[playerid] = 1;
  141. }
  142. }
  143. }
  144. return 1;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment