Advertisement
bgtracker

Fireworks Script

Jun 10th, 2012
2,293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.27 KB | None | 0 0
  1. /*
  2.  
  3. --------------CREDITS:-----------------------
  4. --------------RG-GAMING.INFO------------------------
  5. ---------------------------------------------------
  6.  
  7.  
  8. ---------------------------------------------------
  9. --------------DEFINING FILTERSCRIPT----------------
  10. ---------------------------------------------------
  11. */
  12. #define FILTERSCRIPT
  13. /*
  14. ---------------------------------------------------
  15. --------------INCLUDES-----------------------------
  16. ---------------------------------------------------
  17. */
  18. #include <a_samp>
  19. #include <zcmd>
  20. #include <sscanf2>
  21. #include <foreach>
  22. #include <streamer>
  23. /*
  24. ---------------------------------------------------
  25. --------------COLOR DEFINES------------------------
  26. ---------------------------------------------------
  27. */
  28. #define COLOR_GREY 0xAFAFAFAA
  29. #define COLOR_WHITE 0xFFFFFFAA
  30. #define COLOR_YELLOW 0xFFFF00AA
  31. #define RocketHeight 50
  32. #define RocketSpread 30
  33. #define MAX_LAUNCH 20
  34. #define MAX_FIREWORKS 100
  35. /*
  36. ---------------------------------------------------
  37. --------------NEW VARIABLES------------------------
  38. ---------------------------------------------------
  39. */
  40. new Rocket[MAX_LAUNCH];
  41. new RocketLight[MAX_LAUNCH];
  42. new RocketSmoke[MAX_LAUNCH];
  43. new RocketExplosions[MAX_LAUNCH];
  44. new Float:rx[MAX_LAUNCH];
  45. new Float:ry[MAX_LAUNCH];
  46. new Float:rz[MAX_LAUNCH];
  47. new FireworkTotal;
  48. new Fired;
  49. /*
  50. ---------------------------------------------------
  51. --------------Getting the player's name------------
  52. ---------------------------------------------------
  53. */
  54. GetPlayerNameEx(playerid) {
  55.  
  56.     new sz_playerName[MAX_PLAYER_NAME], i_pos;
  57.  
  58.     GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  59.     while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  60.     return sz_playerName;
  61. }
  62.  
  63. /*
  64. ---------------------------------------------------
  65. --------------The actual fireworks function--------
  66. ---------------------------------------------------
  67. */
  68. forward Firework(i);
  69. public Firework(i)
  70. {
  71.     new Float:x, Float:y, Float:z;
  72.     x = rx[i];
  73.     y = ry[i];
  74.     z = rz[i];
  75.     z += RocketHeight;
  76.     if (RocketExplosions[i] == 0)
  77.     {
  78.         DestroyDynamicObject(Rocket[i]);
  79.         DestroyDynamicObject(RocketLight[i]);
  80.         DestroyDynamicObject(RocketSmoke[i]);
  81.         CreateExplosion(x ,y, z, 4, 10);
  82.         CreateExplosion(x ,y, z, 5, 10);
  83.         CreateExplosion(x ,y, z, 6, 10);
  84.     }
  85.     else if (RocketExplosions[i] >= MAX_FIREWORKS)
  86.     {
  87.         for (new j = 0; j <= RocketSpread; j++)
  88.         {
  89.             CreateExplosion(x + float(j - (RocketSpread / 2)), y, z, 7, 10);
  90.             CreateExplosion(x, y + float(j - (RocketSpread / 2)), z, 7, 10);
  91.             CreateExplosion(x, y, z + float(j - (RocketSpread / 2)), 7, 10);
  92.         }
  93.         RocketExplosions[i] = -1;
  94.         FireworkTotal = 0;
  95.         Fired = 0;
  96.         return 1;
  97.     }
  98.     else
  99.     {
  100.         x += float(random(RocketSpread) - (RocketSpread / 2));
  101.         y += float(random(RocketSpread) - (RocketSpread / 2));
  102.         z += float(random(RocketSpread) - (RocketSpread / 2));
  103.         CreateExplosion(x, y, z, 7, 10);
  104.     }
  105.     RocketExplosions[i]++;
  106.     SetTimerEx("Firework", 250, 0, "i", i);
  107.     return 1;
  108. }
  109. /*
  110. ---------------------------------------------------
  111. --------------COMMANDS FOR FIREWORKS---------------
  112. ---------------------------------------------------
  113. */
  114. CMD:placefw(playerid, params[])
  115. {
  116.         if(FireworkTotal == MAX_LAUNCH)
  117.         {
  118.             SendClientMessage(playerid, COLOR_WHITE, "You have reached maximum number of fireworks!");
  119.             return 1;
  120.         }
  121.         if(Fired == 1)
  122.         {
  123.             SendClientMessage(playerid, COLOR_WHITE, "Wait till your fireworks are done before placing new ones!");
  124.             return 1;
  125.         }
  126.         new string[128];
  127.         format(string, sizeof(string), "%s has placed a special firework.", GetPlayerNameEx(playerid));
  128.         new Float:x, Float:y, Float:z, Float:a;
  129.         GetPlayerPos(playerid, x, y, z);
  130.         foreach(Player, i)
  131.         {
  132.             if(IsPlayerInRangeOfPoint(i, 30, x, y, z)) {
  133.                 SendClientMessage(i, COLOR_YELLOW, string);
  134.             }
  135.         }
  136.         GetPlayerFacingAngle(playerid, a);
  137.         x += (2 * floatsin(-a, degrees));
  138.         y += (2 * floatcos(-a, degrees));
  139.         Rocket[FireworkTotal] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
  140.         RocketLight[FireworkTotal] = CreateDynamicObject(354, x, y, z + 1, 0, 90, 0);
  141.         RocketSmoke[FireworkTotal] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
  142.         rx[FireworkTotal] = x;
  143.         ry[FireworkTotal] = y;
  144.         rz[FireworkTotal] = z;
  145.         RocketExplosions[FireworkTotal] = 0;
  146.         FireworkTotal++;
  147.         return 1;
  148.     }
  149.  
  150. CMD:launchfw(playerid, params[])
  151. {
  152.         if(FireworkTotal == 0)
  153.         {
  154.             SendClientMessage(playerid, COLOR_WHITE, "You dont have any fireworks!");
  155.             return 1;
  156.         }
  157.         if(Fired == 1)
  158.         {
  159.             SendClientMessage(playerid, COLOR_WHITE, "You have already fired your fireworks!");
  160.             return 1;
  161.         }
  162.         for(new i = 0; i < FireworkTotal; i++)
  163.         {
  164.             CreateExplosion(rx[i] ,ry[i], rz[i], 12, 5);
  165.             new time = MoveDynamicObject(Rocket[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  166.             MoveDynamicObject(RocketLight[i], rx[i] ,ry[i], rz[i] + 2 + RocketHeight, 10);
  167.             MoveDynamicObject(RocketSmoke[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  168.             SetTimerEx("Firework", time, 0, "i", i);
  169.         }
  170.         Fired = 1;
  171.         return 1;
  172.     }
  173.    
  174. /*
  175. ---------------------------------------------------
  176. --------------THE END------------------------
  177. ---------------------------------------------------
  178. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement