Guest User

fireworksys.pwn

a guest
May 4th, 2014
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. // Credits an Includes
  4. // If something wrong goes with color white, Fix it because I was in a hurry!
  5.  
  6. #include <a_samp> // SA-MP Team
  7. #include <zcmd> // Zeex
  8. #include <sscanf2> // Y_Less the Smart One :D
  9. #include <foreach> // Y_Less the Smart One AGAIN :D
  10. #include <streamer> // Incognito
  11.  
  12. #define RocketHeight 70 // You can edit this
  13. #define RocketSpread 30 // Spread till
  14. #define MAX_LAUNCH 20 // Max Could be launched
  15. #define MAX_FIREWORKS 100 // Max Fireworks had
  16. #define COLOR_YELLOW 0xFFFF00AA // Credits = SA-MP Forums
  17.  
  18. new Rocket[MAX_LAUNCH];
  19. new RocketLight[MAX_LAUNCH];
  20. new RocketSmoke[MAX_LAUNCH];
  21. new RocketExplosions[MAX_LAUNCH];
  22. new Float:rx[MAX_LAUNCH];
  23. new Float:ry[MAX_LAUNCH];
  24. new Float:rz[MAX_LAUNCH];
  25. new FireworkTotal;
  26. new Fired;
  27.  
  28. GetPlayerNameEx(playerid) {
  29.  
  30. new sz_playerName[MAX_PLAYER_NAME], i_pos;
  31.  
  32. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  33. while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  34. return sz_playerName;
  35. }
  36.  
  37. // Ahh nvm lets get to Firework
  38.  
  39. forward Firework(i);
  40. public Firework(i)
  41. {
  42. new Float:x, Float:y, Float:z;
  43. x = rx[i];
  44. y = ry[i];
  45. z = rz[i];
  46. z += RocketHeight;
  47. if (RocketExplosions[i] == 0)
  48. {
  49. DestroyDynamicObject(Rocket[i]);
  50. DestroyDynamicObject(RocketLight[i]);
  51. DestroyDynamicObject(RocketSmoke[i]);
  52. CreateExplosion(x ,y, z, 4, 10);
  53. CreateExplosion(x ,y, z, 5, 10);
  54. CreateExplosion(x ,y, z, 6, 10);
  55. }
  56. else if (RocketExplosions[i] >= MAX_FIREWORKS)
  57. {
  58. for (new j = 0; j <= RocketSpread; j++)
  59. {
  60. CreateExplosion(x + float(j - (RocketSpread / 2)), y, z, 7, 10);
  61. CreateExplosion(x, y + float(j - (RocketSpread / 2)), z, 7, 10);
  62. CreateExplosion(x, y, z + float(j - (RocketSpread / 2)), 7, 10);
  63. }
  64. RocketExplosions[i] = -1;
  65. FireworkTotal = 0;
  66. Fired = 0;
  67. return 1;
  68. }
  69. else
  70. {
  71. x += float(random(RocketSpread) - (RocketSpread / 2));
  72. y += float(random(RocketSpread) - (RocketSpread / 2));
  73. z += float(random(RocketSpread) - (RocketSpread / 2));
  74. CreateExplosion(x, y, z, 7, 10);
  75. }
  76. RocketExplosions[i]++;
  77. SetTimerEx("Firework", 250, 0, "i", i);
  78. return 1;
  79. }
  80.  
  81. CMD:placefirework(playerid, params[])
  82. {
  83. if(FireworkTotal == MAX_LAUNCH)
  84. {
  85. SendClientMessage(playerid, 0xFFFFFFAA, "ERROR:{FFFFFF}You have reached maximum number of fireworks! Max 20!");
  86. return 1;
  87. }
  88. if(Fired == 1)
  89. {
  90. SendClientMessage(playerid, 0xFFFFFFAA, "ERROR:{FFFFFF}Wait till your fireworks are done before placing new ones!");
  91. return 1;
  92. }
  93. new string[128];
  94. format(string, sizeof(string), "%s has placed a special firework.", GetPlayerNameEx(playerid));
  95. new Float:x, Float:y, Float:z, Float:a;
  96. GetPlayerPos(playerid, x, y, z);
  97. foreach(Player, i)
  98. {
  99. if(IsPlayerInRangeOfPoint(i, 30, x, y, z)) {
  100. SendClientMessage(i, COLOR_YELLOW, string);
  101. }
  102. }
  103. GetPlayerFacingAngle(playerid, a);
  104. x += (2 * floatsin(-a, degrees));
  105. y += (2 * floatcos(-a, degrees));
  106. Rocket[FireworkTotal] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
  107. RocketLight[FireworkTotal] = CreateDynamicObject(354, x, y, z + 1, 0, 90, 0);
  108. RocketSmoke[FireworkTotal] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
  109. rx[FireworkTotal] = x;
  110. ry[FireworkTotal] = y;
  111. rz[FireworkTotal] = z;
  112. RocketExplosions[FireworkTotal] = 0;
  113. FireworkTotal++;
  114. return 1;
  115. }
  116.  
  117. CMD:launchfirework(playerid, params[])
  118. {
  119. if(FireworkTotal == 0)
  120. {
  121. SendClientMessage(playerid, 0xFFFFFFAA, "ERROR:{FFFFFF}You dont have any fireworks!");
  122. return 1;
  123. }
  124. if(Fired == 1)
  125. {
  126. SendClientMessage(playerid, 0xFFFFFFAA, "ERROR:{FFFFFF}]You have already fired your fireworks!");
  127. return 1;
  128. }
  129. for(new i = 0; i < FireworkTotal; i++)
  130. {
  131. CreateExplosion(rx[i] ,ry[i], rz[i], 12, 5);
  132. new time = MoveDynamicObject(Rocket[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  133. MoveDynamicObject(RocketLight[i], rx[i] ,ry[i], rz[i] + 2 + RocketHeight, 10);
  134. MoveDynamicObject(RocketSmoke[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  135. SetTimerEx("Firework", time, 0, "i", i);
  136. }
  137. Fired = 1;
  138. return 1;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment