Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. /*
  2. Grenade Launcher v1.0
  3. Made by Jelly23
  4. */
  5.  
  6. /*Defined as filterscript*/
  7. #define FILTERSCRIPT
  8.  
  9. /*Includes*/
  10. #include <a_samp>
  11. #include <izcmd>
  12. #include <MapAndreas>
  13.  
  14. /*Vars*/
  15. new Float:aPos[MAX_PLAYERS],
  16. stage[MAX_PLAYERS],
  17. TotalGrenades = -1;
  18.  
  19. /*Do not touch*/
  20. #define player_dist 0.1
  21. #define launch_dist 10.0
  22. #define grenade_dist 15.0
  23.  
  24. /*Enumerator*/
  25. enum Grenades
  26. {
  27. GrenadeObj,
  28. gPlayer
  29. }
  30. new gData[MAX_OBJECTS][Grenades];
  31.  
  32. public OnFilterScriptInit()
  33. {
  34. print("\n--------------------------------------");
  35. print(" Grenade Launcher v1.0 - Made by Jelly23");
  36. print("--------------------------------------\n");
  37. return 1;
  38. }
  39.  
  40. public OnFilterScriptExit()
  41. {
  42. return 1;
  43. }
  44.  
  45. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  46. {
  47. if (newkeys & KEY_WALK)
  48. {
  49. if(GetPlayerWeapon(playerid) == 31)
  50. {
  51. if(IsPlayerAiming(playerid))
  52. {
  53. if(stage[playerid] == 0)
  54. {
  55. new Float:x, Float:y, Float:z;
  56. TotalGrenades++;
  57. GetPlayerPos(playerid, x, y, z);
  58. stage[playerid] = 1;
  59. GetPlayerPos(playerid, x, y, aPos[playerid]);
  60. GetPlayerFacingAngle(playerid, aPos[playerid]);
  61. x += (player_dist * floatsin(-aPos[playerid], degrees));
  62. y += (player_dist * floatcos(-aPos[playerid], degrees));
  63. gData[TotalGrenades][GrenadeObj] = CreateObject(342, x, y, z+0.4, 0, 0, 96);
  64. gData[TotalGrenades][gPlayer] = playerid;
  65. GetPlayerPos(playerid, x, y, aPos[playerid]);
  66. GetPlayerFacingAngle(playerid, aPos[playerid]);
  67. x += (launch_dist * floatsin(-aPos[playerid], degrees));
  68. y += (launch_dist * floatcos(-aPos[playerid], degrees));
  69. MoveObject(gData[TotalGrenades][GrenadeObj], x, y, z+3, 20.00);
  70. }
  71. else
  72. {
  73. SendClientMessage(playerid,-1,"Wait before launching another grenade");
  74. }
  75. }
  76. }
  77. }
  78. return 1;
  79. }
  80. public OnPlayerConnect(playerid)
  81. {
  82. stage[playerid] = 0;
  83. return 1;
  84. }
  85.  
  86. IsPlayerAiming(playerid)
  87. {
  88. new anim = GetPlayerAnimationIndex(playerid);
  89. if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) ||
  90. (anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
  91. return 0;
  92. }
  93.  
  94. public OnObjectMoved(objectid)
  95. {
  96. new Float:x, Float:y, Float:z;
  97. if(stage[gData[TotalGrenades][gPlayer]] == 1)
  98. {
  99. GetObjectPos(gData[TotalGrenades][GrenadeObj], x, y, z);
  100. CA_FindZ_For2DCoord(x,y,z);
  101. x += (grenade_dist * floatsin(-aPos[gData[TotalGrenades][gPlayer]], degrees));
  102. y += (grenade_dist * floatcos(-aPos[gData[TotalGrenades][gPlayer]], degrees));
  103. MoveObject(gData[TotalGrenades][GrenadeObj], x, y, z, 20.00);
  104. stage[gData[TotalGrenades][gPlayer]] = 2;
  105. }
  106. else if(stage[gData[TotalGrenades][gPlayer]] == 2)
  107. {
  108. GetObjectPos(gData[TotalGrenades][GrenadeObj], x, y, z);
  109. stage[gData[TotalGrenades][gPlayer]] = 0;
  110. DestroyObject(gData[TotalGrenades][GrenadeObj]);
  111. TotalGrenades--;
  112. CreateExplosion(x, y, z, 2, 10.0);
  113. }
  114. return 1;
  115. }
  116.  
  117. CMD:test(playerid) return GivePlayerWeapon(playerid,31,100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement