peinneon

Noobist Airstrike System

Dec 24th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.46 KB | None | 0 0
  1. // Noobist Airstrike System.
  2. // Credits: Kye (SA-MP, MapAndreas), ZeeX (ZCMD), Y_Less (foreach), sheen (Concept)
  3. // You need MapAndreas plugin from Kye to run this filterscript
  4. // MapAndreas: http://forum.sa-mp.com/showthread.php?t=120013
  5. // You can edit and share this filterscript, but don't remove any credits.
  6.  
  7. #define FILTERSCRIPT
  8.  
  9. #include <a_samp>
  10. #include <zcmd>
  11. #include <foreach>
  12. #include <mapandreas>
  13.  
  14. forward CallAirstrike(playerid);
  15. forward AirstrikeCheck(playerid, AS1, AS2, AS3, AS4, AS5, Float:AZ1, Float:AZ2, Float:AZ3, Float:AZ4, Float:AZ5);
  16. forward PlaneCheck(playerid);
  17.  
  18. new A1[MAX_PLAYERS];
  19. new A2[MAX_PLAYERS];
  20. new A3[MAX_PLAYERS];
  21. new A4[MAX_PLAYERS];
  22. new A5[MAX_PLAYERS];
  23. new ATimer[MAX_PLAYERS];
  24. new ACheck[MAX_PLAYERS];
  25. new APlane[MAX_PLAYERS];
  26. new PCheck[MAX_PLAYERS];
  27.  
  28. public OnFilterScriptInit()
  29. {
  30.     MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  31.     foreach(Player, p) OnPlayerConnect(p);
  32.     print("\n--------------------------------------");
  33.     print(" Noobist Airstrike System Loaded");
  34.     print("--------------------------------------\n");
  35.     return 1;
  36. }
  37.  
  38. public OnFilterScriptExit()
  39. {
  40.     foreach(Player, p)
  41.     {
  42.         DeletePVar(p, "AX");
  43.         DeletePVar(p, "AY");
  44.         DeletePVar(p, "HasA");
  45.         DeletePVar(p, "MapClicked");
  46.         DeletePVar(p, "ADestroyed");
  47.         if(IsValidObject(A1[p])) DestroyObject(A1[p]);
  48.         if(IsValidObject(A2[p])) DestroyObject(A2[p]);
  49.         if(IsValidObject(A3[p])) DestroyObject(A3[p]);
  50.         if(IsValidObject(A4[p])) DestroyObject(A4[p]);
  51.         if(IsValidObject(A5[p])) DestroyObject(A5[p]);
  52.         if(IsValidObject(APlane[p])) DestroyObject(APlane[p]);
  53.         KillTimer(ATimer[p]);
  54.         KillTimer(ACheck[p]);
  55.         KillTimer(PCheck[p]);
  56.     }
  57.     print("\n--------------------------------------");
  58.     print(" Noobist Airstrike System Unloaded");
  59.     print("--------------------------------------\n");
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerConnect(playerid)
  64. {
  65.     SendClientMessage(playerid, 0x00FF00, "This server Airstrike System is powered by Noobist Airstrike System, /strikehelp for more information.");
  66.     return 1;
  67. }
  68.  
  69. public OnPlayerDisconnect(playerid, reason)
  70. {
  71.     if(IsValidObject(A1[playerid])) DestroyObject(A1[playerid]);
  72.     if(IsValidObject(A2[playerid])) DestroyObject(A2[playerid]);
  73.     if(IsValidObject(A3[playerid])) DestroyObject(A3[playerid]);
  74.     if(IsValidObject(A4[playerid])) DestroyObject(A4[playerid]);
  75.     if(IsValidObject(A5[playerid])) DestroyObject(A5[playerid]);
  76.     if(IsValidObject(APlane[playerid])) DestroyObject(APlane[playerid]);
  77.     KillTimer(ATimer[playerid]);
  78.     KillTimer(ACheck[playerid]);
  79.     KillTimer(PCheck[playerid]);
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  84. {
  85.     SetPVarFloat(playerid, "AX", fX);
  86.     SetPVarFloat(playerid, "AY", fY);
  87.     SetPVarInt(playerid, "MapClicked", 1);
  88.     return 1;
  89. }
  90.  
  91. CMD:callstrike(playerid)
  92. {
  93.     if(GetPVarInt(playerid, "HasA") == 0) return SendClientMessage(playerid, 0xFF0000, "You don't have permission to call an airstrike.");
  94.     if(GetPVarInt(playerid, "HasA") >= 2) return SendClientMessage(playerid, 0xFF0000, "You can't call airstrike twice.");
  95.     if(GetPVarInt(playerid, "MapClicked") == 0) return SendClientMessage(playerid, 0xFF0000, "Please specify the target. (Menu -> Map -> Target)");
  96.     SendClientMessage(playerid, 0x00FF00, "Calling the airstrike, you can abort it with /abortstrike.");
  97.     SetPVarInt(playerid, "HasA", 2);
  98.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  99.     SetPlayerAttachedObject(playerid, 4, 330, 6);
  100.     ATimer[playerid] = SetTimerEx("CallAirstrike", 10000, false, "i", playerid);
  101.     return 1;
  102. }
  103.  
  104. CMD:abortstrike(playerid)
  105. {
  106.     if(GetPVarInt(playerid, "HasA") == 0) return SendClientMessage(playerid, 0xFF0000, "You don't have permission to call an airstrike.");
  107.     if(GetPVarInt(playerid, "HasA") == 3) return SendClientMessage(playerid, 0xFF0000, "Airstrike already called, cannot abort.");
  108.     SendClientMessage(playerid, 0x00FF00, "Airstrike aborted.");
  109.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
  110.     RemovePlayerAttachedObject(playerid, 4);
  111.     KillTimer(ATimer[playerid]);
  112.     SetPVarInt(playerid, "HasA", 1);
  113.     return 1;
  114. }
  115.  
  116. public CallAirstrike(playerid)
  117. {
  118.     if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_USECELLPHONE)
  119.     {
  120.         SendClientMessage(playerid, 0xFF0000, "Airstrike call failed.");
  121.         RemovePlayerAttachedObject(playerid, 4);
  122.         SetPVarInt(playerid, "HasA", 1);
  123.         return 1;
  124.     }
  125.     new Float:AZP;
  126.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
  127.     SendClientMessage(playerid, 0x00FF00, "Airstrike has been successfully called.");
  128.     RemovePlayerAttachedObject(playerid, 4);
  129.     SetPVarInt(playerid, "HasA", 3);
  130.     MapAndreas_FindZ_For2DCoord(floatsub(GetPVarFloat(playerid, "AX"), 100.0), GetPVarFloat(playerid, "AY"), AZP);
  131.     APlane[playerid] = CreateObject(1683, floatsub(GetPVarFloat(playerid, "AX"), 100.0), GetPVarFloat(playerid, "AY"), floatadd(AZP, 110.0), 0.0, 0.0, 0.0);
  132.     MoveObject(APlane[playerid], floatadd(GetPVarFloat(playerid, "AX"), 200.0), GetPVarFloat(playerid, "AY"), floatadd(AZP, 110.0), 20.0);
  133.     PCheck[playerid] = SetTimerEx("PlaneCheck", 100, true, "i", playerid);
  134.     return 1;
  135. }
  136.  
  137. public PlaneCheck(playerid)
  138. {
  139.     new Float:APX, Float:APY, Float:APZ;
  140.     GetObjectPos(APlane[playerid], APX, APY, APZ);
  141.     if(floatsub(floatadd(GetPVarFloat(playerid, "AX"), 200.0), APX) < 2)
  142.     {
  143.         DestroyObject(APlane[playerid]);
  144.         KillTimer(PCheck[playerid]);
  145.         return 1;
  146.     }
  147.     if(floatsub(GetPVarFloat(playerid, "AX"), APX) < 1 && GetPVarInt(playerid, "HasA") != 4)
  148.     {
  149.         new Float:AZ1, Float:AZ2, Float:AZ3, Float:AZ4, Float:AZ5;
  150.         MapAndreas_FindZ_For2DCoord(GetPVarFloat(playerid, "AX"), GetPVarFloat(playerid, "AY"), AZ1);
  151.         MapAndreas_FindZ_For2DCoord(GetPVarFloat(playerid, "AX")+5.0, GetPVarFloat(playerid, "AY"), AZ2);
  152.         MapAndreas_FindZ_For2DCoord(GetPVarFloat(playerid, "AX")-5.0, GetPVarFloat(playerid, "AY"), AZ3);
  153.         MapAndreas_FindZ_For2DCoord(GetPVarFloat(playerid, "AX"), GetPVarFloat(playerid, "AY")+5.0, AZ4);
  154.         MapAndreas_FindZ_For2DCoord(GetPVarFloat(playerid, "AX"), GetPVarFloat(playerid, "AY")-5.0, AZ5);
  155.         A1[playerid] = CreateObject(354, GetPVarFloat(playerid, "AX"), GetPVarFloat(playerid, "AY"), floatadd(AZ1, 100.0), 0.0, 0.0, 0.0);
  156.         A2[playerid] = CreateObject(354, floatadd(GetPVarFloat(playerid, "AX"), 5.0), GetPVarFloat(playerid, "AY"), floatadd(AZ1, 100.0), 0.0, 0.0, 0.0);
  157.         A3[playerid] = CreateObject(354, floatsub(GetPVarFloat(playerid, "AX"), 5.0), GetPVarFloat(playerid, "AY"), floatadd(AZ1, 100.0), 0.0, 0.0, 0.0);
  158.         A4[playerid] = CreateObject(354, GetPVarFloat(playerid, "AX"), floatadd(GetPVarFloat(playerid, "AY"), 5.0), floatadd(AZ1, 100.0), 0.0, 0.0, 0.0);
  159.         A5[playerid] = CreateObject(354, GetPVarFloat(playerid, "AX"), floatsub(GetPVarFloat(playerid, "AY"), 5.0), floatadd(AZ1, 100.0), 0.0, 0.0, 0.0);
  160.         MoveObject(A1[playerid], GetPVarFloat(playerid, "AX"), GetPVarFloat(playerid, "AY"), AZ1, 10.0);
  161.         MoveObject(A2[playerid], floatadd(GetPVarFloat(playerid, "AX"), 5.0), GetPVarFloat(playerid, "AY"), AZ2, 10.0);
  162.         MoveObject(A3[playerid], floatsub(GetPVarFloat(playerid, "AX"), 5.0), GetPVarFloat(playerid, "AY"), AZ3, 10.0);
  163.         MoveObject(A4[playerid], GetPVarFloat(playerid, "AX"), floatadd(GetPVarFloat(playerid, "AY"), 5.0), AZ4, 10.0);
  164.         MoveObject(A5[playerid], GetPVarFloat(playerid, "AX"), floatsub(GetPVarFloat(playerid, "AY"), 5.0), AZ5, 10.0);
  165.         ACheck[playerid] = SetTimerEx("AirstrikeCheck", 100, true, "iiiiiifffff", playerid, A1[playerid], A2[playerid], A3[playerid], A4[playerid], A5[playerid], AZ1, AZ2, AZ3, AZ4, AZ5);
  166.         SetPVarInt(playerid, "HasA", 4);
  167.         return 1;
  168.     }
  169.     return 1;
  170. }
  171.  
  172. public AirstrikeCheck(playerid, AS1, AS2, AS3, AS4, AS5, Float:AZ1, Float:AZ2, Float:AZ3, Float:AZ4, Float:AZ5)
  173. {
  174.     new Float:AX, Float:AY, Float:AZ;
  175.     if(IsValidObject(AS1))
  176.     {
  177.         GetObjectPos(AS1, AX, AY, AZ);
  178.         foreach(Player, p)
  179.         {
  180.             if(GetPlayerDistanceFromPoint(p, AX, AY, AZ) < 4)
  181.             {
  182.                 CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  183.                 CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  184.                 CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  185.                 CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  186.                 DestroyObject(AS1);
  187.                 SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  188.             }
  189.         }
  190.         if(floatsub(AZ, AZ1) < 1)
  191.         {
  192.             CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  193.             CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  194.             CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  195.             CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  196.             DestroyObject(AS1);
  197.             SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  198.         }
  199.     }
  200.     if(IsValidObject(AS2))
  201.     {
  202.         GetObjectPos(AS2, AX, AY, AZ);
  203.         foreach(Player, p)
  204.         {
  205.             if(GetPlayerDistanceFromPoint(p, AX, AY, AZ) < 4)
  206.             {
  207.                 CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  208.                 CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  209.                 CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  210.                 CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  211.                 DestroyObject(AS2);
  212.                 SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  213.             }
  214.         }
  215.         if(floatsub(AZ, AZ2) < 1)
  216.         {
  217.             CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  218.             CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  219.             CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  220.             CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  221.             DestroyObject(AS2);
  222.             SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  223.         }
  224.     }
  225.     if(IsValidObject(AS3))
  226.     {
  227.         GetObjectPos(AS3, AX, AY, AZ);
  228.         foreach(Player, p)
  229.         {
  230.             if(GetPlayerDistanceFromPoint(p, AX, AY, AZ) < 4)
  231.             {
  232.                 CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  233.                 CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  234.                 CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  235.                 CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  236.                 DestroyObject(AS3);
  237.                 SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  238.             }
  239.         }
  240.         if(floatsub(AZ, AZ3) < 1)
  241.         {
  242.             CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  243.             CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  244.             CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  245.             CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  246.             DestroyObject(AS3);
  247.             SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  248.         }
  249.     }
  250.     if(IsValidObject(AS4))
  251.     {
  252.         GetObjectPos(AS4, AX, AY, AZ);
  253.         foreach(Player, p)
  254.         {
  255.             if(GetPlayerDistanceFromPoint(p, AX, AY, AZ) < 4)
  256.             {
  257.                 CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  258.                 CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  259.                 CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  260.                 CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  261.                 DestroyObject(AS4);
  262.                 SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  263.             }
  264.         }
  265.         if(floatsub(AZ, AZ4) < 1)
  266.         {
  267.             CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  268.             CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  269.             CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  270.             CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  271.             DestroyObject(AS4);
  272.             SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  273.         }
  274.     }
  275.     if(IsValidObject(AS5))
  276.     {
  277.         GetObjectPos(AS5, AX, AY, AZ);
  278.         foreach(Player, p)
  279.         {
  280.             if(GetPlayerDistanceFromPoint(p, AX, AY, AZ) < 4)
  281.             {
  282.                 CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  283.                 CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  284.                 CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  285.                 CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  286.                 DestroyObject(AS5);
  287.                 SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  288.             }
  289.         }
  290.         if(floatsub(AZ, AZ5) < 1)
  291.         {
  292.             CreateExplosion(AX+1, AY, AZ, 0, 10.0);
  293.             CreateExplosion(AX-1, AY, AZ, 0, 10.0);
  294.             CreateExplosion(AX, AY+1, AZ, 0, 10.0);
  295.             CreateExplosion(AX, AY-1, AZ, 0, 10.0);
  296.             DestroyObject(AS5);
  297.             SetPVarInt(playerid, "ADestroyed", GetPVarInt(playerid, "ADestroyed")+1);
  298.         }
  299.     }
  300.     if(GetPVarInt(playerid, "ADestroyed") == 5)
  301.     {
  302.         SetPVarInt(playerid, "HasA", 0);
  303.         DeletePVar(playerid, "ADestroyed");
  304.         KillTimer(ACheck[playerid]);
  305.         return 1;
  306.     }
  307.     return 1;
  308. }
  309.  
  310. CMD:givestrike(playerid)
  311. {
  312.     if(!IsPlayerAdmin(playerid)) return 0;
  313.     SetPVarInt(playerid, "HasA", 1);
  314.     SendClientMessage(playerid, 0x00FF00, "You have got permission to call an airstrike.");
  315.     return 1;
  316. }
  317.  
  318. CMD:buystrikepermission(playerid)
  319. {
  320.     if(!IsPlayerInRangeOfPoint(playerid, 20.0, 2447.1755, -1972.8712, 13.5469)) return SendClientMessage(playerid, 0xFF0000, "You must be in Emmet's place to buy that!");
  321.     if(GetPlayerMoney(playerid) < 50000) return SendClientMessage(playerid, 0xFF0000, "You need $50000 to buy that!");
  322.     if(GetPVarInt(playerid, "HasA") > 0) return SendClientMessage(playerid, 0xFF0000, "You can't buy it twice!");
  323.     SetPVarInt(playerid, "HasA", 1);
  324.     GivePlayerMoney(playerid, -50000);
  325.     SendClientMessage(playerid, 0x00FF00, "You have bought permission to call an airstrike, use /callstrike to call an airstrike.");
  326.     return 1;
  327. }
  328.  
  329. CMD:strikehelp(playerid)
  330. {
  331.     SendClientMessage(playerid, 0xFF0000, "Noobist Airstrike System.");
  332.     SendClientMessage(playerid, 0xFF0000, "Credits: Kye (SA-MP, MapAndreas), ZeeX (ZCMD), Y_Less (foreach), sheen (Concept)");
  333.     SendClientMessage(playerid, 0xFF0000, "/buystrikepermission -> Buy an airstrike permission (Must be in Emmet's place)");
  334.     SendClientMessage(playerid, 0xFF0000, "/callstrike -> Call an airstrike");
  335.     SendClientMessage(playerid, 0xFF0000, "/abortstrike -> Abort an airstrike");
  336.     if(IsPlayerAdmin(playerid)) SendClientMessage(playerid, 0xFF0000, "RCON Admin CMD: /givestrike -> Free airstrike permission");
  337.     return 1;
  338. }
Advertisement
Add Comment
Please, Sign In to add comment