Guest User

eBOMB

a guest
Oct 31st, 2014
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.89 KB | None | 0 0
  1. /*
  2.         eBOMB - Bomb system by [Su37]Erich
  3. */
  4. #include "a_samp"
  5. #include "foreach"
  6. #include "streamer"
  7. #include "mapandreas"
  8.  
  9. /*------------------PERSONALIZAR-------------------------------*/
  10. #define MAX_PLAYER          39  //Change this for the amount of slots that you have in your server
  11. #define LOAD_MAPANDREAS         //Delete this line if you have already the MapAndreas plugin (This function enable minimal mode)
  12. #define BOMBS               4   //Change this for the amount of bombs that will be launched pressing the key N
  13. #define TIME                30  //Change this for the amount of time before you can launch bombs again (seconds)
  14.  
  15. new Iterator:Bombs<10000>;
  16. new O_P = 0;
  17. new Last_Fire[MAX_PLAYER];
  18. new Launch_ID[MAX_PLAYER];
  19. #define FILTERSCRIPT
  20. public OnFilterScriptInit()
  21. {
  22.     SetTimer("Count_Objects", 10000, false);
  23.     #if defined LOAD_MAPANDREAS
  24.     MapAndreas_Init(MAP_ANDREAS_MODE_MINIMAL);
  25.     #endif 
  26.     print("---------------------------------------------");
  27.     print("eBOMB by Su-37 Erich loaded");
  28.     print("---------------------------------------------");
  29.     return 1;
  30. }
  31. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  32. {
  33.     if(IsPlayerInAnyVehicle(playerid))
  34.     {
  35.         if(newkeys & KEY_NO)
  36.         {
  37.             switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
  38.             {
  39.                 case 553, 476:
  40.                 {
  41.                     if(GetTickCount() - Last_Fire[playerid] < TIME*1000)
  42.                     {
  43.                         new string[108];
  44.                         format(string, sizeof(string), "Wait %d seconds before you can launch bombs again", TIME);
  45.                         return SendClientMessage(playerid, 0x00FF11FF, string);
  46.                     }
  47.                     Last_Fire[playerid] = GetTickCount();
  48.                     SetPVarInt(playerid, "Amount", BOMBS);
  49.                     Launch_ID[playerid] = SetTimerEx("Drop_Bombs", 400, true, "d", playerid);
  50.                 }
  51.             }
  52.         }
  53.     }
  54.     return 1;
  55. }
  56. forward Drop_Bombs(playerid);
  57. public Drop_Bombs(playerid)
  58. {
  59.     if(GetPVarInt(playerid, "Amount") <= 0)
  60.         return KillTimer(Launch_ID[playerid]);
  61.     SetPVarInt(playerid, "Amount", GetPVarInt(playerid, "Amount") -1);
  62.     new Float:X, Float:Y, Float:Z;
  63.     if(!IsPlayerInAnyVehicle(playerid) || !IsPlayerConnected(playerid))
  64.         return KillTimer(Launch_ID[playerid]);
  65.     GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
  66.     new id = CreateDynamicObject(3786, X, Y, Z-3.0, 0.0, 0.0, 0.0);
  67.     MapAndreas_FindZ_For2DCoord(X, Y, Z);
  68.     MoveDynamicObject(id, X, Y, Z, 30.0);
  69.     Iter_Add(Bombs, id-O_P);
  70.     return 1;
  71. }
  72. public OnDynamicObjectMoved(objectid)
  73. {
  74.     foreach(new i : Bombs)
  75.     {
  76.         if(objectid == i+O_P)
  77.         {
  78.             new Float:x,Float:y,Float:z;
  79.             GetDynamicObjectPos(i+O_P, x, y, z);
  80.             CreateExplosion(x, y, z, 6, 100.0);
  81.             CreateExplosion(x+4.0, y, z, 6, 100.0);
  82.             CreateExplosion(x, y+4.0, z, 6, 100.0);
  83.             DestroyDynamicObject(i+O_P);
  84.             new next;
  85.             Iter_SafeRemove(Bombs, i, next);
  86.             i = next;
  87.         }
  88.     }
  89. }
  90. forward Count_Objects();
  91. public Count_Objects()
  92. {
  93.     for(new i = 0; i<500000; i++)
  94.     {
  95.         if(IsValidDynamicObject(i))
  96.             O_P++;
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment