fireworks.pwn 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Fireworks System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. forward Firework(playerid, type);
  34. public Firework(playerid, type)
  35. {
  36. if(!IsPlayerConnected(playerid))
  37. {
  38. DestroyDynamicObject(Rocket[playerid]);
  39. DestroyDynamicObject(RocketLight[playerid]);
  40. DestroyDynamicObject(RocketSmoke[playerid]);
  41. return 1;
  42. }
  43. new Float:x, Float:y, Float:z;
  44. x = GetPVarFloat(playerid, "fxpos");
  45. y = GetPVarFloat(playerid, "fypos");
  46. z = GetPVarFloat(playerid, "fzpos");
  47. if (type == TYPE_COUNTDOWN)
  48. {
  49. new string[128];
  50. format(string, sizeof(string), "STAND BACK! 5 seconds till launch!", GetPlayerNameEx(playerid));
  51. ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
  52. SetTimerEx("Firework", 5000, 0, "ii", playerid, TYPE_LAUNCH);
  53. }
  54. else if(type == TYPE_LAUNCH)
  55. {
  56. CreateExplosion(x ,y, z, 12, 5);
  57. new time = MoveDynamicObject(Rocket[playerid], x, y, z + RocketHeight, 10);
  58. MoveDynamicObject(RocketLight[playerid], x, y, z + 2 + RocketHeight, 10);
  59. MoveDynamicObject(RocketSmoke[playerid], x, y, z + RocketHeight, 10);
  60. SetTimerEx("Firework", time, 0, "ii", playerid, TYPE_EXPLODE);
  61. }
  62. else if(type == TYPE_EXPLODE)
  63. {
  64. z += RocketHeight;
  65. if (RocketExplosions[playerid] == 0)
  66. {
  67. DestroyDynamicObject(Rocket[playerid]);
  68. DestroyDynamicObject(RocketLight[playerid]);
  69. DestroyDynamicObject(RocketSmoke[playerid]);
  70. CreateExplosion(x ,y, z, 4, 10);
  71. CreateExplosion(x ,y, z, 5, 10);
  72. CreateExplosion(x ,y, z, 6, 10);
  73. }
  74. else if (RocketExplosions[playerid] >= MAX_FIREWORKS)
  75. {
  76. for (new i = 0; i <= FireworkSpread; i++)
  77. {
  78. CreateExplosion(x + float(i - (FireworkSpread / 2)), y, z, 7, 10);
  79. CreateExplosion(x, y + float(i - (FireworkSpread / 2)), z, 7, 10);
  80. CreateExplosion(x, y, z + float(i - (FireworkSpread / 2)), 7, 10);
  81. }
  82. RocketExplosions[playerid] = -1;
  83. return 1;
  84. }
  85. else
  86. {
  87. x += float(random(FireworkSpread) - (FireworkSpread / 2));
  88. y += float(random(FireworkSpread) - (FireworkSpread / 2));
  89. z += float(random(FireworkSpread) - (FireworkSpread / 2));
  90. CreateExplosion(x, y, z, 7, 10);
  91. }
  92. RocketExplosions[playerid]++;
  93. SetTimerEx("Firework", 250, 0, "ii", playerid, TYPE_EXPLODE);
  94. }
  95. return 1;
  96. }
  97. CMD:placefirework(playerid, params[])
  98. {
  99. if(fireworktog == 0 || GetPVarInt(playerid, "camerasc") == 1 || GetPVarInt(playerid, "rccam") == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot currently launch fireworks.");
  100. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be Level 3+ to place a firework!");
  101. if(GetPVarType(playerid, "IsInArena")) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this while being in an arena!");
  102. if(GetPVarInt(playerid, "WatchingTV")) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot do this while watching TV!");
  103. if(GetPVarInt(playerid, "Injured") == 1 || PlayerInfo[playerid][pHospital] > 0 || IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this right now.");
  104. if(RocketExplosions[playerid] != -1) return SendClientMessageEx(playerid, COLOR_WHITE, "You are already using another firework!");
  105. if (PlayerInfo[playerid][pVW] != 0 || PlayerInfo[playerid][pInt] != 0) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't launch fireworks indoors!");
  106. if(PlayerInfo[playerid][pFirework] > 0 || PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  107. {
  108. new Float:x, Float:y, Float:z, Float:a;
  109. GetPlayerPos(playerid, x, y, z);
  110. GetPlayerFacingAngle(playerid, a);
  111. if(dynamicgift != 0) // Currently a dynamic gift is placed down
  112. {
  113. new Float: Pos[3];
  114. GetDynamicObjectPos(dynamicgift, Pos[0], Pos[1], Pos[2]);
  115. if(IsPlayerInRangeOfPoint(playerid, 50.0, Pos[0], Pos[1], Pos[2]))
  116. return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot place a firework down near the giftbox.");
  117. }
  118. if (PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1)
  119. {
  120. PlayerInfo[playerid][pFirework]--;
  121. }
  122. new string[128];
  123. format(string, sizeof(string), "%s has placed a firework which will go off in 30 seconds!", GetPlayerNameEx(playerid));
  124. ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
  125. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
  126. x += (2 * floatsin(-a, degrees));
  127. y += (2 * floatcos(-a, degrees));
  128. Rocket[playerid] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
  129. RocketLight[playerid] = CreateDynamicObject(354, x, y, z + 1, 0, 0, 0);
  130. RocketSmoke[playerid] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
  131. SetPVarFloat(playerid,"fxpos",x);
  132. SetPVarFloat(playerid,"fypos",y);
  133. SetPVarFloat(playerid,"fzpos",z);
  134. RocketExplosions[playerid] = 0;
  135. SetTimerEx("Firework", 25000, 0, "ii", playerid, TYPE_COUNTDOWN);
  136. }
  137. else
  138. {
  139. SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have any fireworks!");
  140. }
  141. return 1;
  142. }
  143. CMD:togfireworks(playerid, params[])
  144. {
  145. if(PlayerInfo[playerid][pAdmin] >= 1337)
  146. {
  147. if(fireworktog == 0)
  148. {
  149. fireworktog = 1;
  150. SendClientMessageEx(playerid, COLOR_WHITE, "You have enabled the placement of fireworks.");
  151. }
  152. else
  153. {
  154. fireworktog = 0;
  155. SendClientMessageEx(playerid, COLOR_WHITE, "You have disabled the placement of fireworks.");
  156. }
  157. }
  158. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not authorized to use this command.");
  159. return 1;
  160. }
  161. CMD:fireworknear(playerid, params[])
  162. {
  163. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  164. {
  165. new Float: pos[3];
  166. SendClientMessageEx(playerid, COLOR_RED, "* Listing all fireworks within 50 meters of you...");
  167. foreach(new i : Player)
  168. {
  169. if(RocketExplosions[i] != -1)
  170. {
  171. new string[128];
  172. pos[0] = GetPVarFloat(i, "fxpos");
  173. pos[1] = GetPVarFloat(i, "fypos");
  174. pos[2] = GetPVarFloat(i, "fzpos");
  175. if(IsPlayerInRangeOfPoint(playerid, 50, pos[0], pos[1], pos[2]))
  176. {
  177. format(string, sizeof(string), "** Firework Owner: %s | %f from you", GetPlayerNameEx(i), GetPlayerDistanceFromPoint(playerid, GetPVarFloat(i, "fxpos"), GetPVarFloat(i, "fypos"), GetPVarFloat(i, "fzpos")));
  178. SendClientMessageEx(playerid, COLOR_WHITE, string);
  179. }
  180. }
  181. }
  182. }
  183. else
  184. return SendClientMessageEx(playerid, COLOR_GRAD1, "You're not authorized to use this command!");
  185. return true;
  186. }