Advertisement
Janchuks

[v1] Firework System

Jan 24th, 2013
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.35 KB | None | 0 0
  1. // ______ _                 _                   ______
  2. //| ___ \ |               | |                 |___  /
  3. //| |_/ / |__   __ _ _ __ | |_ ___  _ __ ___     / /
  4. //|  __/| '_ \ / _` | '_ \| __/ _ \| '_ ` _ \   / /
  5. //| |   | | | | (_| | | | | || (_) | | | | | |./ /___
  6. //\_|   |_| |_|\__,_|_| |_|\__\___/|_| |_| |_|\_____/
  7.  
  8. #define FILTERSCRIPT
  9.  
  10. #include <a_samp>
  11. #include <zcmd>
  12. #include <sscanf2>
  13. #include <foreach>
  14. #include <streamer>
  15.  
  16. #define COLOR_GREY 0xAFAFAFAA
  17. #define COLOR_WHITE 0xFFFFFFAA
  18. #define COLOR_YELLOW 0xFFFF00AA
  19. #define RocketHeight 50
  20. #define RocketSpread 30
  21. #define MAX_LAUNCH 20
  22. #define MAX_FIREWORKS 100
  23.  
  24. new Rocket[MAX_LAUNCH];
  25. new RocketLight[MAX_LAUNCH];
  26. new RocketSmoke[MAX_LAUNCH];
  27. new RocketExplosions[MAX_LAUNCH];
  28. new Float:rx[MAX_LAUNCH];
  29. new Float:ry[MAX_LAUNCH];
  30. new Float:rz[MAX_LAUNCH];
  31. new FireworkTotal;
  32. new Fired;
  33.  
  34. GetPlayerNameEx(playerid) {
  35.  
  36.     new sz_playerName[MAX_PLAYER_NAME], i_pos;
  37.  
  38.     GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  39.     while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  40.     return sz_playerName;
  41. }
  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.  
  85. public OnFilterScriptInit()
  86. {
  87.    
  88. }
  89.  
  90. public OnFilterScriptExit()
  91. {
  92.  
  93. }
  94.  
  95. CMD:placefw(playerid, params[])
  96. {
  97.     if(IsPlayerAdmin(playerid))
  98.     {
  99.         if(FireworkTotal == MAX_LAUNCH)
  100.         {
  101.             SendClientMessage(playerid, COLOR_WHITE, "You have reached maximum number of fireworks you have placed!");
  102.             return 1;
  103.         }
  104.         if(Fired == 1)
  105.         {
  106.             SendClientMessage(playerid, COLOR_WHITE, "Wait till your fireworks are done before placing new ones! (Just not for Spam)");
  107.             return 1;
  108.         }
  109.         new string[128];
  110.         format(string, sizeof(string), "%s has placed a firework.", GetPlayerNameEx(playerid));
  111.         new Float:x, Float:y, Float:z, Float:a;
  112.         GetPlayerPos(playerid, x, y, z);
  113.         foreach(Player, i)
  114.         {
  115.             if(IsPlayerInRangeOfPoint(i, 30, x, y, z)) {
  116.                 SendClientMessage(i, COLOR_YELLOW, string);
  117.             }
  118.         }
  119.         GetPlayerFacingAngle(playerid, a);
  120.         x += (2 * floatsin(-a, degrees));
  121.         y += (2 * floatcos(-a, degrees));
  122.         Rocket[FireworkTotal] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
  123.         RocketLight[FireworkTotal] = CreateDynamicObject(354, x, y, z + 1, 0, 90, 0);
  124.         RocketSmoke[FireworkTotal] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
  125.         rx[FireworkTotal] = x;
  126.         ry[FireworkTotal] = y;
  127.         rz[FireworkTotal] = z;
  128.         RocketExplosions[FireworkTotal] = 0;
  129.         FireworkTotal++;
  130.     }
  131.     return 1;
  132. }
  133.  
  134. CMD:launchfw(playerid, params[])
  135. {
  136.     if(IsPlayerAdmin(playerid))
  137.     {
  138.         if(FireworkTotal == 0)
  139.         {
  140.             SendClientMessage(playerid, COLOR_WHITE, "You dont have any fireworks! Get some.");
  141.             return 1;
  142.         }
  143.         if(Fired == 1)
  144.         {
  145.             SendClientMessage(playerid, COLOR_WHITE, "You have already fired your fireworks!");
  146.             return 1;
  147.         }
  148.         for(new i = 0; i < FireworkTotal; i++)
  149.         {
  150.             CreateExplosion(rx[i] ,ry[i], rz[i], 12, 5);
  151.             new time = MoveDynamicObject(Rocket[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  152.             MoveDynamicObject(RocketLight[i], rx[i] ,ry[i], rz[i] + 2 + RocketHeight, 10);
  153.             MoveDynamicObject(RocketSmoke[i], rx[i] ,ry[i], rz[i] + RocketHeight, 10);
  154.             SetTimerEx("Firework", time, 0, "i", i);
  155.         }
  156.         Fired = 1;
  157.     }
  158.     return 1;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement