Guest User

SWAT cannon

a guest
Jun 3rd, 2015
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. new firedcannon[MAX_PLAYERS];
  2.  
  3. stock randomEx(min, max)
  4. {
  5. new rand9 = random(max-min)+min;
  6. return rand9;
  7. }//credits to yless
  8.  
  9. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  10. {
  11. if(newkeys == KEY_FIRE)
  12. {
  13. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 601)
  14. {
  15. if(firedcannon[playerid] == 0)
  16. {
  17. firedcannon[playerid] = 1;
  18. SetTimerEx("cannonfired", 1000, false,"i",playerid);
  19. new
  20. Float:x8, Float:y8, Float:z8,
  21. Float:x2, Float:y2, Float:z2,
  22. Float:x7, Float:y7, Float:z7,
  23. Float:object_x, Float:object_y, Float:object_z;
  24. GetPlayerPos(playerid,x7,y7,z7);
  25. GetPlayerCameraPos(playerid, x8,y8,z8);
  26. GetPlayerCameraFrontVector(playerid, x2,y2,z2);
  27.  
  28.  
  29.  
  30. new sa = randomEx(30, 100);
  31.  
  32.  
  33. object_x = x8 + floatmul(x2, sa);
  34. object_y = y8 + floatmul(y2, sa);
  35.  
  36.  
  37. MapAndreas_FindZ_For2DCoord(object_x, object_y, object_z);
  38.  
  39. if(z8+floatmul(z2, sa) < object_z)
  40. {
  41. foreach (new i : Player)
  42. {
  43. if(GetPlayerTeam(i) != (GetPlayerTeam(playerid)))
  44. {
  45. if(i != playerid)
  46. {
  47. if(IsPlayerInRangeOfPoint(i,40,x7,y7,z7))
  48. {
  49. GetPlayerPos(i,x7,y7,z7);
  50. if(GetPlayerCameraFrontVector(playerid, x7,y7,z7))
  51. {
  52. CreateExplosion(x7,y7,z7, 12, 5.0);
  53. }
  54. }
  55. }
  56. else CreateExplosion(object_x, object_y, object_z, 12, 5.0);
  57. }
  58. else CreateExplosion(object_x, object_y, object_z, 12, 5.0);
  59. }
  60. }
  61. else if(z8+floatmul(z2, sa) > object_z)
  62. {
  63. foreach (new i : Player)
  64. {
  65. if(GetPlayerTeam(i) != (GetPlayerTeam(playerid)))
  66. {
  67. if(i != playerid)
  68. {
  69. if(IsPlayerInRangeOfPoint(i,6,x7,y7,z7))
  70. {
  71. GetPlayerPos(i,x7,y7,z7);
  72. if(GetPlayerCameraFrontVector(playerid, x7,y7,z7))
  73. {
  74. CreateExplosion(x7,y7,z7, 12, 5.0);
  75. new Float:HP;
  76. GetPlayerHealth(i, HP);
  77. if(GetPlayerHealth(i,HP) <= 0)
  78. {
  79. if(i != playerid)
  80. {
  81. SetPlayerScore(playerid, GetPlayerScore(playerid) + 4);
  82. GivePlayerMoney(playerid,4000);
  83. SendClientMessage(playerid, COLOR_LIGHTGREEN, "Good Job on Killing him, you recived +4 scores and 4000$ money");
  84. SetPlayerScore(i, GetPlayerScore(playerid) - 1);
  85. GivePlayerMoney(i,-2000);
  86. }
  87. }
  88. }
  89. }
  90. }
  91. else CreateExplosion(object_x, object_y, z8+floatmul(z2, sa), 12, 5.0);
  92. }
  93. else CreateExplosion(object_x, object_y, z8+floatmul(z2, sa), 12, 5.0);
  94. }
  95. }
  96. foreach (new i : Player)
  97. {
  98. if(i != playerid)
  99. {
  100. new Float:HP;
  101. GetPlayerHealth(i, HP);
  102. if(GetPlayerHealth(i,HP) <= 0)
  103. {
  104. if(IsPlayerInRangeOfPoint(i,5,object_x, object_y, object_z))
  105. {
  106. SetPlayerScore(playerid, GetPlayerScore(playerid) + 4);
  107. GivePlayerMoney(playerid,4000);
  108. SendClientMessage(playerid, COLOR_LIGHTGREEN, "Good Job on Killing him, you recived +4 scores and 4000$ money");
  109. SetPlayerScore(i, GetPlayerScore(playerid) - 1);
  110. GivePlayerMoney(i,-2000);
  111. }
  112. }
  113. }
  114. }
  115.  
  116. }
  117. }
  118. }
  119. return 1;
  120. }
  121.  
  122. forward cannonfired(playerid);
  123. public cannonfired(playerid)
  124. {
  125. firedcannon[playerid] = 0;
  126. return 1;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment