Inshal

iBomb v1.1 by inshal

Aug 22nd, 2014
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.79 KB | None | 0 0
  1. /*===================================CREDITS====================================
  2.                             FILTER SCRIPT CREATED BY
  3.                                     inshal
  4.                         [iBomb] Attach Bomb to a player
  5.                                     V1.1
  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. //==============================================================================
  24.  
  25.  
  26. //==============================FORWARDS========================================
  27. forward OneSVariables();
  28. forward Explosion();
  29. forward Float:GetDistanceBetweenPlayers(p1,p2);
  30. //==============================================================================
  31.  
  32.  
  33.  
  34. //===============================COLORS=========================================
  35. #define RED 0xFF0000AA
  36. #define LIGHTGREEN 0x33AA33AA
  37. #define GREY 0xAFAFAFAA
  38. //==============================================================================
  39. public OnFilterScriptInit()
  40. {
  41.         print("\n--------------------------------------");
  42.         print(" iBomb Filterscript v1.1 loaded!");
  43.         print("--------------------------------------\n");
  44.        
  45.         SetTimer("OneSVariables",1000,1);
  46.        
  47. //=================================TEXTDRAWS====================================
  48.         Bomb = TextDrawCreate(503.500000, 127.750053, "Bombed");
  49.         TextDrawLetterSize(Bomb, 0.449999, 1.600000);
  50.         TextDrawAlignment(Bomb, 1);
  51.         TextDrawColor(Bomb, RED);
  52.         TextDrawSetShadow(Bomb, 0);
  53.         TextDrawSetOutline(Bomb, 1);
  54.         TextDrawBackgroundColor(Bomb, 51);
  55.         TextDrawFont(Bomb, 3);
  56.         TextDrawSetProportional(Bomb, 1);
  57. //==============================================================================
  58.         return 1;
  59. }
  60.  
  61. public OnFilterScriptExit()
  62. {
  63.         print("\n----------------------------------");
  64.         print(" iBomb Filterscript v1.1 unloaded!");
  65.         print("----------------------------------\n");
  66.         return 1;
  67. }
  68.  
  69. public OnPlayerConnect(playerid)
  70. {
  71.         SendClientMessage(playerid, LIGHTGREEN, "iBomb v1.1 by inshal is successfully being used in this server.");
  72.         return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77.         TextDrawDestroy(Bomb);
  78.         return 1;
  79. }
  80.  
  81. public OnPlayerSpawn(playerid)
  82. {
  83.         AttemptedToBombRecently[playerid] =0;
  84.         HasBombedRecently[playerid] =0;
  85.         AttemptedToDefuseBombRecently[playerid] =0;
  86.         BombAttached[playerid] =0;
  87.         TextDrawHideForPlayer(playerid, Bomb);
  88.         return 1;
  89. }
  90.  
  91. public OnPlayerDeath(playerid, killerid, reason)
  92. {
  93.         AttemptedToBombRecently[playerid] =0;
  94.         HasBombedRecently[playerid] =0;
  95.         AttemptedToDefuseBombRecently[playerid] =0;
  96.         BombAttached[playerid] =0;
  97.         TextDrawHideForPlayer(playerid, Bomb);
  98.         return 1;
  99. }
  100.  
  101. public OnVehicleSpawn(vehicleid)
  102. {
  103.         return 1;
  104. }
  105.  
  106. public OnVehicleDeath(vehicleid, killerid)
  107. {
  108.         return 1;
  109. }
  110.  
  111. public OnPlayerText(playerid, text[])
  112. {
  113.         return 1;
  114. }
  115.  
  116. //================================COMMANDS======================================
  117.  
  118. CMD:bomb(playerid,params[])
  119. {
  120.         new targetid, string[128], pName[MAX_PLAYER_NAME+1];
  121.         new crand = random(50);
  122.         if(GetDistanceBetweenPlayers(playerid, targetid) > 4) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player is too far away.");
  123.         if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, RED, "[USAGE]{FFFFFF} /bomb [name/id]")&&
  124.                                                  SendClientMessage(playerid, GREY, "[FUNCTION]{FFFFFF} Will attach a bomb to a player.");
  125.         if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player not found.");
  126.         if(BombAttached[targetid] == 1) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} A bomb is already attached to the player.");
  127.         if(playerid == targetid) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} You cannot attach a bomb on yourself!");
  128.         if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} The player is in a vehicle.");
  129.         if(HasBombedRecently[playerid] >= 1)
  130.         {
  131.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before bombing someone again.",HasBombedRecently[playerid]);
  132.             SendClientMessage(playerid,RED,string);
  133.             return 1;
  134.         }
  135.         if(AttemptedToBombRecently[playerid] >= 1)
  136.         {
  137.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to bomb someone again.",AttemptedToBombRecently[playerid]);
  138.             SendClientMessage(playerid,RED,string);
  139.             return 1;
  140.         }
  141.         if(crand <= 25) return AttemptedToBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to attach the bomb on the player.");
  142.         if(crand > 25)
  143.         {
  144.             GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  145.             SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have attached the bomb on the player and it will detonate in 10 seconds.");
  146.             SendClientMessage(targetid, RED, "[DANGER]{FFFFFF} A bomb has been attached on you and will detonate in 10 seconds!");
  147.             SendClientMessage(targetid, GREY, "[TIP]{FFFFFF} You can try to defuse the bomb by using /defusebomb.");
  148.             SetTimer("Explosion", 10000, false);
  149.             BombAttached[targetid] =1;
  150.             TextDrawShowForPlayer(playerid, Bomb);
  151.             HasBombedRecently[playerid] =60;
  152.             //SetPVarString(playerid, "Name", pName);
  153.             //SetPVarInt(playerid, "ID", playerid);
  154.         }
  155.         return 1;
  156. }
  157.  
  158. CMD:defusebomb(playerid,params[])
  159. {
  160.         new crand = random(40), string[128];
  161.         if(BombAttached[playerid] == 1) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} There is no bomb attached on you.");
  162.         if(AttemptedToDefuseBombRecently[playerid] >= 1)
  163.         {
  164.             format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to defuse a bomb again.",AttemptedToDefuseBombRecently[playerid]);
  165.             SendClientMessage(playerid,RED,string);
  166.             return 1;
  167.         }
  168.         if(crand <= 20) return AttemptedToDefuseBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to defuse the bomb.");
  169.         if(crand > 20)
  170.         {
  171.             SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have successfully defused the bomb.");
  172.             BombAttached[playerid] =0;
  173.             TextDrawHideForPlayer(playerid, Bomb);
  174.         }
  175.         return 1;
  176. }
  177. //==============================================================================
  178. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  179. {
  180.         return 1;
  181. }
  182.  
  183. public OnPlayerExitVehicle(playerid, vehicleid)
  184. {
  185.         return 1;
  186. }
  187.  
  188. public OnPlayerStateChange(playerid, newstate, oldstate)
  189. {
  190.         return 1;
  191. }
  192.  
  193. public OnPlayerEnterCheckpoint(playerid)
  194. {
  195.         return 1;
  196. }
  197.  
  198. public OnPlayerLeaveCheckpoint(playerid)
  199. {
  200.         return 1;
  201. }
  202.  
  203. public OnPlayerEnterRaceCheckpoint(playerid)
  204. {
  205.         return 1;
  206. }
  207.  
  208. public OnPlayerLeaveRaceCheckpoint(playerid)
  209. {
  210.         return 1;
  211. }
  212.  
  213. public OnRconCommand(cmd[])
  214. {
  215.         return 1;
  216. }
  217.  
  218. public OnPlayerRequestSpawn(playerid)
  219. {
  220.         return 1;
  221. }
  222.  
  223. public OnObjectMoved(objectid)
  224. {
  225.         return 1;
  226. }
  227.  
  228. public OnPlayerObjectMoved(playerid, objectid)
  229. {
  230.         return 1;
  231. }
  232.  
  233. public OnPlayerPickUpPickup(playerid, pickupid)
  234. {
  235.         return 1;
  236. }
  237.  
  238. public OnVehicleMod(playerid, vehicleid, componentid)
  239. {
  240.         return 1;
  241. }
  242.  
  243. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  244. {
  245.         return 1;
  246. }
  247.  
  248. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  249. {
  250.         return 1;
  251. }
  252.  
  253. public OnPlayerSelectedMenuRow(playerid, row)
  254. {
  255.         return 1;
  256. }
  257.  
  258. public OnPlayerExitedMenu(playerid)
  259. {
  260.         return 1;
  261. }
  262.  
  263. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  264. {
  265.         return 1;
  266. }
  267.  
  268. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  269. {
  270.         return 1;
  271. }
  272.  
  273. public OnRconLoginAttempt(ip[], password[], success)
  274. {
  275.         return 1;
  276. }
  277.  
  278. public OnPlayerUpdate(playerid)
  279. {
  280.         return 1;
  281. }
  282.  
  283. public OnPlayerStreamIn(playerid, forplayerid)
  284. {
  285.         return 1;
  286. }
  287.  
  288. public OnPlayerStreamOut(playerid, forplayerid)
  289. {
  290.         return 1;
  291. }
  292.  
  293. public OnVehicleStreamIn(vehicleid, forplayerid)
  294. {
  295.         return 1;
  296. }
  297.  
  298. public OnVehicleStreamOut(vehicleid, forplayerid)
  299. {
  300.         return 1;
  301. }
  302.  
  303. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  304. {
  305.         return 1;
  306. }
  307.  
  308. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  309. {
  310.         return 1;
  311. }
  312.  
  313.  
  314. //================================STOCKS AND OTHERS=============================
  315. public Explosion()
  316. {
  317.         for(new i=0; i<MAX_PLAYERS; i++)
  318.         {
  319.             if(IsPlayerConnected(i))
  320.             {
  321.                 if(BombAttached[i] == 1)
  322.                 {
  323.                 new string[128], Float:x, Float:y, Float:z;
  324.                 //new pName[MAX_PLAYER_NAME+1];
  325.                 GetPlayerPos(i, x, y, z);
  326.                 CreateExplosion(x,y,z,6,10.0);
  327.                 SetPlayerHealth(i, 0);
  328.                 BombAttached[i] =0;
  329.                 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")*/);
  330.                 SendClientMessageToAll(RED, string);
  331.                 TextDrawHideForPlayer(i, Bomb);
  332.                 }
  333.             }
  334.         }
  335. }
  336.  
  337. public OneSVariables()
  338. {
  339.     for(new i=0; i<MAX_PLAYERS; i++)
  340.     {
  341.         if(IsPlayerConnected(i))
  342.         {
  343.             if(HasBombedRecently[i] >= 1)
  344.             {
  345.                 HasBombedRecently[i] --;
  346.             }
  347.  
  348.             if(AttemptedToBombRecently[i] >= 1)
  349.             {
  350.                 AttemptedToBombRecently[i] --;
  351.             }
  352.             if(AttemptedToDefuseBombRecently[i] >= 1)
  353.             {
  354.                 AttemptedToDefuseBombRecently[i] --;
  355.             }
  356.  
  357.         }
  358.     }
  359. }
  360. public Float:GetDistanceBetweenPlayers(p1,p2)
  361. {
  362.         new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  363.         if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  364.         {
  365.                 return -1.00;
  366.         }
  367.         GetPlayerPos(p1,x1,y1,z1);
  368.         GetPlayerPos(p2,x2,y2,z2);
  369.         return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  370. }
  371.  
  372. stock GetName(playerid)
  373. {
  374.     new Name[MAX_PLAYER_NAME];
  375.     GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  376.     return Name;
  377. }
  378. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment