Advertisement
Rei_Ayanami

iBomb v1.2 by inshal

Apr 29th, 2024
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*===================================CREDITS====================================
  2.                             FILTER SCRIPT CREATED BY
  3.                                     inshal
  4.                         [iBomb] Attach Bomb to a player
  5.                                     v1.2
  6.                 http://forum.sa-mp.com/showthread.php?p=2961629
  7. //============================================================================*/
  8.  
  9.  
  10. //=================================INCLUDES=====================================
  11. #include <a_samp>
  12. #include <sscanf2>
  13. #include <zcmd>
  14. //==============================================================================
  15.  
  16.  
  17. //==================================NEW=========================================
  18. new BombAttached[MAX_PLAYERS];
  19. new AttemptedToBombRecently[MAX_PLAYERS];
  20. new HasBombedRecently[MAX_PLAYERS];
  21. new AttemptedToDefuseBombRecently[MAX_PLAYERS];
  22. new Text:Bomb;
  23. new Text:ExpTime[3];
  24. new VehicleBombed[MAX_VEHICLES];
  25. new HasBlownVehicleRecently[MAX_PLAYERS];
  26. new ExplosionTime[MAX_PLAYERS];
  27. //==============================================================================
  28.  
  29.  
  30. //==============================FORWARDS========================================
  31. forward OneSVariables();
  32. forward Explosion();
  33. forward Float:GetDistanceBetweenPlayers(p1,p2);
  34. //==============================================================================
  35.  
  36.  
  37.  
  38. //===============================COLORS=========================================
  39. #define RED 0xFF0000AA
  40. #define LIGHTGREEN 0x33AA33AA
  41. #define GREY 0xAFAFAFAA
  42. //==============================================================================
  43. public OnFilterScriptInit()
  44. {
  45.         print("\n--------------------------------------");
  46.         print(" iBomb Filterscript v1.2 loaded!");
  47.         print("--------------------------------------\n");
  48.  
  49.         SetTimer("OneSVariables",1000,1);
  50.  
  51. //=================================TEXTDRAWS====================================
  52.         Bomb = TextDrawCreate(503.500000, 127.750053, "Bombed");
  53.         TextDrawLetterSize(Bomb, 0.449999, 1.600000);
  54.         TextDrawAlignment(Bomb, 1);
  55.         TextDrawColor(Bomb, RED);
  56.         TextDrawSetShadow(Bomb, 0);
  57.         TextDrawSetOutline(Bomb, 1);
  58.         TextDrawBackgroundColor(Bomb, 51);
  59.         TextDrawFont(Bomb, 3);
  60.         TextDrawSetProportional(Bomb, 1);
  61.  
  62.         ExpTime[0] = TextDrawCreate(409.500000, 337.500000, "usebox");
  63.         TextDrawLetterSize(ExpTime[0], 0.000000, 2.296668);
  64.         TextDrawTextSize(ExpTime[0], 223.000000, 0.000000);
  65.         TextDrawAlignment(ExpTime[0], 1);
  66.         TextDrawColor(ExpTime[0], 0);
  67.         TextDrawUseBox(ExpTime[0], true);
  68.         TextDrawBoxColor(ExpTime[0], 102);
  69.         TextDrawSetShadow(ExpTime[0], 0);
  70.         TextDrawSetOutline(ExpTime[0], 0);
  71.         TextDrawFont(ExpTime[0], 0);
  72.  
  73.         ExpTime[1] = TextDrawCreate(232.500000, 339.360046, "Explosion time: 10");
  74.         TextDrawLetterSize(ExpTime[1], 0.449999, 1.600000);
  75.         TextDrawAlignment(ExpTime[1], 1);
  76.         TextDrawColor(ExpTime[1], -16776961);
  77.         TextDrawSetShadow(ExpTime[1], 0);
  78.         TextDrawSetOutline(ExpTime[1], 1);
  79.         TextDrawBackgroundColor(ExpTime[1], 51);
  80.         TextDrawFont(ExpTime[1], 3);
  81.         TextDrawSetProportional(ExpTime[1], 1);
  82. //==============================================================================
  83.         return 1;
  84. }
  85.  
  86. public OnFilterScriptExit()
  87. {
  88.         print("\n----------------------------------");
  89.         print(" iBomb Filterscript v1.2 unloaded!");
  90.         print("----------------------------------\n");
  91.         return 1;
  92. }
  93.  
  94. public OnPlayerConnect(playerid)
  95. {
  96.         SendClientMessage(playerid, LIGHTGREEN, "[INFO]{FFFFFF}: iBomb v1.2 by inshal is successfully being used in this server.");
  97.         return 1;
  98. }
  99.  
  100. public OnPlayerDisconnect(playerid, reason)
  101. {
  102.         TextDrawDestroy(Bomb);
  103.         return 1;
  104. }
  105.  
  106. public OnPlayerSpawn(playerid)
  107. {
  108.         AttemptedToBombRecently[playerid] =0;
  109.         HasBombedRecently[playerid] =0;
  110.         AttemptedToDefuseBombRecently[playerid] =0;
  111.         BombAttached[playerid] =0;
  112.         HasBlownVehicleRecently[playerid] =0;
  113.         TextDrawHideForPlayer(playerid, Bomb);
  114.         TextDrawHideForPlayer(playerid, ExpTime[0]);
  115.         TextDrawHideForPlayer(playerid, ExpTime[1]);
  116.         ExplosionTime[playerid] =0;
  117.         return 1;
  118. }
  119.  
  120. public OnPlayerDeath(playerid, killerid, reason)
  121. {
  122.         AttemptedToBombRecently[playerid] =0;
  123.         HasBombedRecently[playerid] =0;
  124.         AttemptedToDefuseBombRecently[playerid] =0;
  125.         BombAttached[playerid] =0;
  126.         HasBlownVehicleRecently[playerid] =0;
  127.         TextDrawHideForPlayer(playerid, Bomb);
  128.         TextDrawHideForPlayer(playerid, ExpTime[0]);
  129.         TextDrawHideForPlayer(playerid, ExpTime[1]);
  130.         ExplosionTime[playerid] =0;
  131.         return 1;
  132. }
  133.  
  134. public OnVehicleSpawn(vehicleid)
  135. {
  136.         return 1;
  137. }
  138.  
  139. public OnVehicleDeath(vehicleid, killerid)
  140. {
  141.         return 1;
  142. }
  143.  
  144. public OnPlayerText(playerid, text[])
  145. {
  146.         return 1;
  147. }
  148.  
  149. //================================COMMANDS======================================
  150. CMD:plantbomb(playerid,params[])
  151. {
  152.     #pragma unused params
  153.     new pName[MAX_PLAYER_NAME], string[128];
  154.     if(!IsPlayerInAnyVehicle(playerid))
  155.     {
  156.         SendClientMessage(playerid,RED,"[ERROR]{FFFFFF} You are not in any vehicle. How are you supposed to blow one up?");
  157.         return 1;
  158.     }
  159.     if(HasBlownVehicleRecently[playerid] >= 1)
  160.     {
  161.         format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before bombing a car again.",HasBlownVehicleRecently[playerid]);
  162.         SendClientMessage(playerid,RED,string);
  163.         return 1;
  164.     }
  165.     new pveh =GetPlayerVehicleID(playerid);
  166.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  167.     SendClientMessage(playerid,RED,"[INFO]{FFFFFF} You have successfully bombed the vehicle and it is about to explode in 10 seconds.");
  168.     HasBlownVehicleRecently[playerid] =120;
  169.     SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
  170.     SetPVarString(playerid, "Name", pName);
  171.     VehicleBombed[pveh] =10;
  172.     return 1;
  173. }
  174.  
  175. CMD:pb(playerid, params[]) return cmd_plantbomb(playerid, params);
  176.  
  177.  
  178. CMD:bomb(playerid,params[])
  179. {
  180.         new targetid, string[128], pName[MAX_PLAYER_NAME+1];
  181.         new crand = random(50);
  182.         if(GetDistanceBetweenPlayers(playerid, targetid) > 4) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player is too far away.");
  183.         if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, RED, "[USAGE]{FFFFFF} /bomb [name/id]")&&
  184.                                                  SendClientMessage(playerid, GREY, "[FUNCTION]{FFFFFF} Will attach a bomb to a player.");
  185.         if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player not found.");
  186.         if(BombAttached[targetid] == 1) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} A bomb is already attached to the player.");
  187. //        if(playerid == targetid) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} You cannot attach a bomb on yourself!");
  188.         if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} The player is in a vehicle.");
  189.         if(HasBombedRecently[playerid] >= 1)
  190.         {
  191.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before bombing someone again.",HasBombedRecently[playerid]);
  192.             SendClientMessage(playerid,RED,string);
  193.             return 1;
  194.         }
  195.         if(AttemptedToBombRecently[playerid] >= 1)
  196.         {
  197.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to bomb someone again.",AttemptedToBombRecently[playerid]);
  198.             SendClientMessage(playerid,RED,string);
  199.             return 1;
  200.         }
  201.         if(crand <= 25) return AttemptedToBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to attach the bomb on the player.");
  202.         if(crand > 25)
  203.         {
  204.             GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  205.             SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have attached the bomb on the player and it will detonate in 10 seconds.");
  206.             SendClientMessage(targetid, RED, "[DANGER]{FFFFFF} A bomb has been attached on you and will detonate in 10 seconds!");
  207.             SendClientMessage(targetid, GREY, "[TIP]{FFFFFF} You can try to defuse the bomb by using /defusebomb.");
  208.             //SetTimer("Explosion", 10000, false);
  209.             BombAttached[targetid] =1;
  210.             TextDrawShowForPlayer(playerid, Bomb);
  211.             HasBombedRecently[playerid] =60;
  212.             //SetPVarString(playerid, "Name", pName);
  213.             //SetPVarInt(playerid, "ID", playerid);
  214.             SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
  215.             SetPlayerAttachedObject(targetid, 2,1252,1,0.10,-0.18,0.01,8.0,85.0,-4.0,0.86,1.16,1.00);
  216.             ExplosionTime[targetid] =10;
  217.             TextDrawShowForPlayer(targetid, ExpTime[0]);
  218.             TextDrawShowForPlayer(targetid, ExpTime[1]);
  219.         }
  220.         return 1;
  221. }
  222.  
  223. CMD:defusebomb(playerid,params[])
  224. {
  225.         new crand = random(40), string[128];
  226.         if(BombAttached[playerid] == 0) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} There is no bomb attached on you.");
  227.         if(AttemptedToDefuseBombRecently[playerid] >= 1)
  228.         {
  229.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to defuse a bomb again.",AttemptedToDefuseBombRecently[playerid]);
  230.             SendClientMessage(playerid,RED,string);
  231.             return 1;
  232.         }
  233.         if(crand <= 20) return AttemptedToDefuseBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to defuse the bomb.");
  234.         if(crand > 20)
  235.         {
  236.             SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have successfully defused the bomb.");
  237.             BombAttached[playerid] =0;
  238.             TextDrawHideForPlayer(playerid, Bomb);
  239.             RemovePlayerAttachedObject(playerid, 2);
  240.             ExplosionTime[playerid] =0;
  241.             TextDrawHideForPlayer(playerid, ExpTime[0]);
  242.             TextDrawHideForPlayer(playerid, ExpTime[1]);
  243.         }
  244.         return 1;
  245. }
  246. //==============================================================================
  247. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  248. {
  249.         return 1;
  250. }
  251.  
  252. public OnPlayerExitVehicle(playerid, vehicleid)
  253. {
  254.         return 1;
  255. }
  256.  
  257. public OnPlayerStateChange(playerid, newstate, oldstate)
  258. {
  259.         return 1;
  260. }
  261.  
  262. public OnPlayerEnterCheckpoint(playerid)
  263. {
  264.         return 1;
  265. }
  266.  
  267. public OnPlayerLeaveCheckpoint(playerid)
  268. {
  269.         return 1;
  270. }
  271.  
  272. public OnPlayerEnterRaceCheckpoint(playerid)
  273. {
  274.         return 1;
  275. }
  276.  
  277. public OnPlayerLeaveRaceCheckpoint(playerid)
  278. {
  279.         return 1;
  280. }
  281.  
  282. public OnRconCommand(cmd[])
  283. {
  284.         return 1;
  285. }
  286.  
  287. public OnPlayerRequestSpawn(playerid)
  288. {
  289.         return 1;
  290. }
  291.  
  292. public OnObjectMoved(objectid)
  293. {
  294.         return 1;
  295. }
  296.  
  297. public OnPlayerObjectMoved(playerid, objectid)
  298. {
  299.         return 1;
  300. }
  301.  
  302. public OnPlayerPickUpPickup(playerid, pickupid)
  303. {
  304.         return 1;
  305. }
  306.  
  307. public OnVehicleMod(playerid, vehicleid, componentid)
  308. {
  309.         return 1;
  310. }
  311.  
  312. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  313. {
  314.         return 1;
  315. }
  316.  
  317. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  318. {
  319.         return 1;
  320. }
  321.  
  322. public OnPlayerSelectedMenuRow(playerid, row)
  323. {
  324.         return 1;
  325. }
  326.  
  327. public OnPlayerExitedMenu(playerid)
  328. {
  329.         return 1;
  330. }
  331.  
  332. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  333. {
  334.         return 1;
  335. }
  336.  
  337. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  338. {
  339.         return 1;
  340. }
  341.  
  342. public OnRconLoginAttempt(ip[], password[], success)
  343. {
  344.         return 1;
  345. }
  346.  
  347. public OnPlayerUpdate(playerid)
  348. {
  349.         return 1;
  350. }
  351.  
  352. public OnPlayerStreamIn(playerid, forplayerid)
  353. {
  354.         return 1;
  355. }
  356.  
  357. public OnPlayerStreamOut(playerid, forplayerid)
  358. {
  359.         return 1;
  360. }
  361.  
  362. public OnVehicleStreamIn(vehicleid, forplayerid)
  363. {
  364.         return 1;
  365. }
  366.  
  367. public OnVehicleStreamOut(vehicleid, forplayerid)
  368. {
  369.         return 1;
  370. }
  371.  
  372. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  373. {
  374.         return 1;
  375. }
  376.  
  377. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  378. {
  379.         return 1;
  380. }
  381.  
  382.  
  383. //================================STOCKS AND OTHERS=============================
  384. /*
  385. public Explosion()
  386. {
  387.         for(new i=0; i<MAX_PLAYERS; i++)
  388.         {
  389.             if(IsPlayerConnected(i))
  390.             {
  391.                 if(BombAttached[i] == 1)
  392.                 {
  393.                 new string[128], Float:x, Float:y, Float:z;
  394.                 //new pName[MAX_PLAYER_NAME+1];
  395.                 GetPlayerPos(i, x, y, z);
  396.                 CreateExplosion(x,y,z,6,10.0);
  397.                 SetPlayerHealth(i, 0);
  398.                 BombAttached[i] =0;
  399.                 format(string, sizeof(string), "[DEATH]{FFFFFF} %s[%d] has been blown up with a bomb" attached by %s[%d]."", GetName(i), i, GetPVarString(i, "Name", pName), GetPVarInt(i, "ID"));
  400.                 SendClientMessageToAll(RED, string);
  401.                 TextDrawHideForPlayer(i, Bomb);
  402.                 }
  403.             }
  404.         }
  405. }
  406. */
  407. public OneSVariables()
  408. {
  409.     for(new i=0; i<MAX_PLAYERS; i++)
  410.     {
  411.         if(IsPlayerConnected(i))
  412.         {
  413.             if(HasBombedRecently[i] >= 1)
  414.             {
  415.                 HasBombedRecently[i] --;
  416.             }
  417.             if(HasBlownVehicleRecently[i] >= 1)
  418.             {
  419.                 HasBlownVehicleRecently[i] --;
  420.             }
  421.             if(AttemptedToBombRecently[i] >= 1)
  422.             {
  423.                 AttemptedToBombRecently[i] --;
  424.             }
  425.             if(AttemptedToDefuseBombRecently[i] >= 1)
  426.             {
  427.                 AttemptedToDefuseBombRecently[i] --;
  428.             }
  429.             if(ExplosionTime[i] >= 1)
  430.             {
  431.                 new string[50];
  432.                 format(string, sizeof(string), "Explosion Time: %d", ExplosionTime[i]);
  433.                 TextDrawSetString(ExpTime[1], string);
  434.                 ExplosionTime[i] --;
  435.             }
  436.             if(ExplosionTime[i] == 0)
  437.             {
  438.                 if(IsPlayerConnected(i))
  439.                 {
  440.                     if(BombAttached[i] == 1)
  441.                     {
  442.                         new string[128], Float:x, Float:y, Float:z;
  443.                         //new pName[MAX_PLAYER_NAME+1];
  444.                         GetPlayerPos(i, x, y, z);
  445.                         CreateExplosion(x,y,z,6,10.0);
  446.                         SetPlayerHealth(i, 0);
  447.                         BombAttached[i] =0;
  448.                         format(string, sizeof(string), "[DEATH]{FFFFFF} %s[%d] has been blown to bits with a bomb."/* attached by %s[%d].*/"", GetName(i), i/*, GetPVarString(i, "Name", pName), GetPVarInt(i, "ID")*/);
  449.                         SendClientMessageToAll(RED, string);
  450.                         TextDrawHideForPlayer(i, Bomb);
  451.                         TextDrawHideForPlayer(i, ExpTime[0]);
  452.                         TextDrawHideForPlayer(i, ExpTime[1]);
  453.                         ExplosionTime[i] =0;
  454.                     }
  455.                 }
  456.             }
  457.             for(new v=0; v<MAX_VEHICLES; v++)
  458.             {
  459.                 if(VehicleBombed[v] > 1)
  460.                 {
  461.                     VehicleBombed[v] --;
  462.                 }
  463.                 if(VehicleBombed[v] == 1)
  464.                 {
  465.                     new Float:x, Float:y, Float:z;
  466.                     GetVehiclePos(v, x, y, z);
  467.                     CreateExplosion(x, y, z, 6, 10.0);
  468.                     SetVehicleToRespawn(v);
  469.                     VehicleBombed[v] =0;
  470.                     SendClientMessageToAll(RED, "[INFO]{FFFFFF} The vehicle which was bombed by %s has been exploded.");
  471.                 }
  472.             }
  473.         }
  474.     }
  475. }
  476. public Float:GetDistanceBetweenPlayers(p1,p2)
  477. {
  478.         new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  479.         if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  480.         {
  481.                 return -1.00;
  482.         }
  483.         GetPlayerPos(p1,x1,y1,z1);
  484.         GetPlayerPos(p2,x2,y2,z2);
  485.         return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  486. }
  487.  
  488. stock GetName(playerid)
  489. {
  490.     new Name[MAX_PLAYER_NAME];
  491.     GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  492.     return Name;
  493. }
  494. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement