firework.pwn 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Next Generation RolePlay 4th of July Fireworks
  11. (created by Next Generation Gaming Development Team)
  12. Combined Credits:
  13. (***) Beren
  14. */
  15. #define FILTERSCRIPT
  16. #include <a_samp>
  17. #include <zcmd>
  18. #include <sscanf2>
  19. #include <foreach>
  20. #include <streamer>
  21. #define COLOR_GREY 0xAFAFAFAA
  22. #define COLOR_WHITE 0xFFFFFFAA
  23. #define COLOR_YELLOW 0xFFFF00AA
  24. #define RocketHeight 50
  25. #define RocketSpread 30
  26. #define MAX_LAUNCH 20
  27. #define MAX_FIREWORKS 100
  28. new Rocket[MAX_LAUNCH];
  29. new RocketLight[MAX_LAUNCH];
  30. new RocketSmoke[MAX_LAUNCH];
  31. new RocketExplosions[MAX_LAUNCH];
  32. new Float:rx[MAX_LAUNCH];
  33. new Float:ry[MAX_LAUNCH];
  34. new Float:rz[MAX_LAUNCH];
  35. new FireworkTotal;
  36. new Fired;
  37. GetPlayerNameEx(playerid) {
  38. new sz_playerName[MAX_PLAYER_NAME], i_pos;
  39. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  40. while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  41. return sz_playerName;
  42. }
  43. forward Firework(i);
  44. public Firework(i)
  45. {
  46. new Float:x, Float:y, Float:z;
  47. x = rx[i];
  48. y = ry[i];
  49. z = rz[i];
  50. z += RocketHeight;
  51. if (RocketExplosions[i] == 0)
  52. {
  53. DestroyDynamicObject(Rocket[i]);
  54. DestroyDynamicObject(RocketLight[i]);
  55. DestroyDynamicObject(RocketSmoke[i]);
  56. CreateExplosion(x ,y, z, 4, 10);
  57. CreateExplosion(x ,y, z, 5, 10);
  58. CreateExplosion(x ,y, z, 6, 10);
  59. }
  60. else if (RocketExplosions[i] >= MAX_FIREWORKS)
  61. {
  62. for (new j = 0; j <= RocketSpread; j++)
  63. {
  64. CreateExplosion(x + float(j - (RocketSpread / 2)), y, z, 7, 10);
  65. CreateExplosion(x, y + float(j - (RocketSpread / 2)), z, 7, 10);
  66. CreateExplosion(x, y, z + float(j - (RocketSpread / 2)), 7, 10);
  67. }
  68. RocketExplosions[i] = -1;
  69. FireworkTotal = 0;
  70. Fired = 0;
  71. return 1;
  72. }
  73. else
  74. {
  75. x += float(random(RocketSpread) - (RocketSpread / 2));
  76. y += float(random(RocketSpread) - (RocketSpread / 2));
  77. z += float(random(RocketSpread) - (RocketSpread / 2));
  78. CreateExplosion(x, y, z, 7, 10);
  79. }
  80. RocketExplosions[i]++;
  81. SetTimerEx("Firework", 250, 0, "i", i);
  82. return 1;
  83. }
  84. public OnFilterScriptInit()
  85. {
  86. }
  87. public OnFilterScriptExit()
  88. {
  89. }
  90. CMD:placefw(playerid, params[])
  91. {
  92. if(IsPlayerAdmin(playerid))
  93. {
  94. if(FireworkTotal == MAX_LAUNCH)
  95. {
  96. SendClientMessage(playerid, COLOR_WHITE, "You have reached maximum number of fireworks!");
  97. return 1;
  98. }
  99. if(Fired == 1)
  100. {
  101. SendClientMessage(playerid, COLOR_WHITE, "Wait till your fireworks are done before placing new ones!");
  102. return 1;
  103. }
  104. new string[128];
  105. format(string, sizeof(string), "%s has placed a special firework.", GetPlayerNameEx(playerid));
  106. new Float:x, Float:y, Float:z, Float:a;
  107. GetPlayerPos(playerid, x, y, z);
  108. foreach(Player, i)
  109. {
  110. if(IsPlayerInRangeOfPoint(i, 30, x, y, z)) {
  111. SendClientMessage(i, COLOR_YELLOW, string);
  112. }
  113. }
  114. GetPlayerFacingAngle(playerid, a);
  115. x += (2 * floatsin(-a, degrees));
  116. y += (2 * floatcos(-a, degrees));
  117. Rocket[FireworkTotal] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
  118. RocketLight[FireworkTotal] = CreateDynamicObject(354, x, y, z + 1, 0, 90, 0);
  119. RocketSmoke[FireworkTotal] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
  120. rx[FireworkTotal] = x;
  121. ry[FireworkTotal] = y;
  122. rz[FireworkTotal] = z;
  123. RocketExplosions[FireworkTotal] = 0;
  124. FireworkTotal++;
  125. }
  126. return 1;
  127. }
  128. CMD:launchfw(playerid, params[])
  129. {
  130. if(IsPlayerAdmin(playerid))
  131. {
  132. if(FireworkTotal == 0)
  133. {
  134. SendClientMessage(playerid, COLOR_WHITE, "You dont have any fireworks!");
  135. return 1;
  136. }
  137. if(Fired == 1)
  138. {
  139. SendClientMessage(playerid, COLOR_WHITE, "You have already fired your fireworks!");
  140. return 1;
  141. }
  142. for(new i = 0; i < FireworkTotal; i++)
  143. {
  144. CreateExplosion(rx[i] ,ry[i], rz[i], 12, 5);
  145. new time = MoveDynamicObject(Rocket[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  146. MoveDynamicObject(RocketLight[i], rx[i] ,ry[i], rz[i] + 2 + RocketHeight, 10);
  147. MoveDynamicObject(RocketSmoke[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  148. SetTimerEx("Firework", time, 0, "i", i);
  149. }
  150. Fired = 1;
  151. }
  152. return 1;
  153. }