Guest User

Swat cannon by verlaj

a guest
Jun 10th, 2014
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 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. new sa = randomEx(30, 100);
  30.  
  31. object_x = x8 + floatmul(x2, sa);
  32. object_y = y8 + floatmul(y2, sa);
  33. object_z = z8 + floatmul(z2, sa);
  34. foreach (new i : Player)
  35. {
  36. if(IsPlayerInRangeOfPoint(i,20,x7,y7,z7))
  37. {
  38. GetPlayerPos(i,x7,y7,z7);
  39. if(GetPlayerCameraFrontVector(playerid, x7,y7,z7))
  40. {
  41. CreateExplosion(x7,y7,z7, 12, 5.0);
  42. }
  43. }
  44. else CreateExplosion(object_x, object_y, object_z+3, 12, 5.0);
  45.  
  46. }
  47.  
  48. }
  49. }
  50. }
  51. return 1;
  52. }
  53.  
  54. forward cannonfired(playerid);
  55. public cannonfired(playerid)
  56. {
  57. firedcannon[playerid] = 0;
  58. return 1;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment