Guest User

[UPDATED] Suicide bomb System V 1.2

a guest
Jun 18th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.51 KB | None | 0 0
  1. //==============================includes ======================================//
  2. #include <a_samp>
  3. #include <foreach>
  4. #include <zcmd>
  5. #include <sscanf2>
  6. //================================Define ======================================//
  7. #define SCM SendClientMessage
  8. #define SCMToAll SendClientMessageToAll
  9. #define SetPlayerHoldingObject(%1,%2,%3,%4,%5,%6,%7,%8,%9) SetPlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1,%2,%3,%4,%5,%6,%7,%8,%9)
  10. #define StopPlayerHoldingObject(%1) RemovePlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
  11. #define IsPlayerHoldingObject(%1) IsPlayerAttachedObjectSlotUsed(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
  12. //================================Color ======================================//
  13. #define COLOR_YELLOW 0xFFFF00AA
  14. #define COLOR_GREEN 0x33AA33AA
  15. #define COLOR_RED 0xFF4500AA
  16. #define COL_WHITE "{FFFFFF}"
  17. #define COL_GREY "{C3C3C3}"
  18. //==============================Varaibles=====================================//
  19. new Bomb[MAX_PLAYERS][3];
  20. new Float:Pos[MAX_PLAYERS][3];
  21. new pObject[MAX_PLAYERS][2];
  22. new Timer[MAX_PLAYERS];
  23. new RANGE;
  24. new RandomCash[] = {1000,1500,2000,1200,800};
  25. new BUTTON_PUSHED[MAX_PLAYERS];
  26. new EXPLODE_BOMB[MAX_PLAYERS];
  27. new EXPLODE_TIMER[MAX_PLAYERS];
  28. new CountDown[MAX_PLAYERS];
  29. new BOMB_OBJECT[MAX_PLAYERS];
  30. new Text3D:BOMB_CD[MAX_PLAYERS];
  31.  
  32.  
  33. public OnFilterScriptInit()
  34. {
  35. print("\n--------------------------------------");
  36. print(" BombSystem Un Loaded ");
  37. print(" Created By Muhammad Bilal ");
  38. print("--------------------------------------\n");
  39. return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44. foreach(Player,i)
  45. {
  46. Bomb[i][0] = 0;
  47. Bomb[i][1] = 0;
  48. Bomb[i][2] = 0;
  49. BUTTON_PUSHED[i] = 0;
  50. Delete3DTextLabel(BOMB_CD[i]);
  51. KillTimer(EXPLODE_TIMER[i]);
  52. KillTimer(EXPLODE_BOMB[i]);
  53. DestroyObject(BOMB_OBJECT[i]);
  54. }
  55. print("\n--------------------------------------");
  56. print(" BombSystem Un Loaded ");
  57. print(" Created By Muhammad Bilal ");
  58. print("--------------------------------------\n");
  59. return 1;
  60. }
  61.  
  62. public OnPlayerConnect(playerid)
  63. {
  64. SCM(playerid,-1,"[SYSTEM]: Bomb System successfully Loaded created by Muhammad Bilal.");
  65. Bomb[playerid][0] = 0;
  66. Bomb[playerid][1] = 0;
  67. Bomb[playerid][2] = 0;
  68. BUTTON_PUSHED[playerid] = 0;
  69. return 1;
  70. }
  71.  
  72. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  73. {
  74. if(newkeys & KEY_YES && !BUTTON_PUSHED[playerid])
  75. {
  76. if(Bomb[playerid][0])
  77. {
  78. if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not allowed to use this bomb using any vehicle.");
  79. BUTTON_PUSHED[playerid] = 1;
  80. CountDown[playerid] = 10;
  81. GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
  82. StopPlayerHoldingObject(playerid);
  83. BOMB_OBJECT[playerid] = CreateObject(1210, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]-0.8, 0, 0, 4);
  84. BOMB_CD[playerid] = Create3DTextLabel("Bomb Created",COLOR_RED , Pos[playerid][0], Pos[playerid][1], Pos[playerid][2],40.0,0);
  85. SCM(playerid, COLOR_GREEN, "Warning: You need to run away from the range of the bomb.");
  86. EXPLODE_TIMER[playerid]= SetTimerEx("OnPlayerBombCountdown",1000,1,"i",playerid);
  87. EXPLODE_BOMB[playerid] = SetTimerEx("OnPlayerUseRemote",10000,0,"i",playerid);
  88. }
  89. if(Bomb[playerid][1])
  90. {
  91. if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not allowed to use this bomb using any vehicle.");
  92. new count = 0,str[128];
  93. GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
  94. CreateExplosion(Pos[playerid][0], Pos[playerid][1], Pos[playerid][2] , 12, 0.0);
  95. Bomb[playerid][1] = 0;
  96. RemovePlayerAttachedObject(playerid,9);
  97. foreach(Player, i)
  98. {
  99. if(IsPlayerInRangeOfPoint(i, RANGE, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]))
  100. {
  101. AppliedBombEffect(i);
  102. if( i != playerid )
  103. {
  104. count++;
  105. }
  106. }
  107. }
  108. if(count > 0)
  109. {
  110. new Random = RandomCash[random(5)];
  111. GivePlayerMoney(playerid,Random);
  112. format(str, sizeof(str), "[NEWS ALERT]: "COL_GREY"-| %d peoples are killed in the suicide bomb attack by suicide bomber %s in San Andreas.|-",count,GetName(playerid));
  113. SCMToAll(COLOR_RED,str);
  114. }
  115. }
  116. }
  117. if((newkeys & KEY_CROUCH || newkeys & KEY_SECONDARY_ATTACK) && Bomb[playerid][2])
  118. {
  119. new count = 0 , str[128];
  120. if(!IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not in any vehicle.");
  121. GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
  122. CreateExplosion(Pos[playerid][0], Pos[playerid][1], Pos[playerid][2] , 12, 0.0);
  123. Bomb[playerid][2] = 0;
  124. foreach(Player,i)
  125. {
  126. if( i != playerid )
  127. {
  128. if(IsPlayerInRangeOfPoint(i, RANGE, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]))
  129. {
  130. AppliedBombEffect(i);
  131. count++;
  132. }
  133. }
  134. }
  135. if(count > 0)
  136. {
  137. new Random = RandomCash[random(5)];
  138. GivePlayerMoney(playerid,Random);
  139. format(str, sizeof(str), "[NEWS ALERT]: "COL_GREY"-| %d peoples are killed in the suicide vehicle bomb attack in San Andreas.|-",count );
  140. SCMToAll(COLOR_RED,str);
  141. }
  142. }
  143. return 1;
  144. }
  145.  
  146. AppliedBombEffect(playerid)
  147. {
  148. GetPlayerPos(playerid,Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
  149. pObject[playerid][0] = CreateObject(18668, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2],0.0,0.0, 0.0);
  150. pObject[playerid][1] = CreateObject(18682, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2],0.0,0.0, 0.0);
  151. SetPlayerAttachedObject(playerid, 0, 2906, 5, -0.2, 0.0, 0.0, 0, 0.0, -90, 1.0, 1.0, 1.0);
  152. SetPlayerAttachedObject(playerid, 1, 2906, 6, -0.2, 0.0, 0.0, 0, 345, 270, 1.0, 1.0, 1.0);
  153. SetPlayerAttachedObject(playerid, 2, 2908, 2, 0.05,0.06, 0.0, 180, 0.0, 90, 1.1, 1.1, 1.1);
  154. SetPlayerAttachedObject(playerid, 3, 2905, 12, 0.1, 0.05, 0.0, 0.0, 0.0, -70, 1.0, 1.0, 1.0);
  155. OnPlayerUseRandomAnim(playerid);
  156. OnPlayerDrunkLevel(playerid);
  157. Timer[playerid] = SetTimerEx("OnPlayerDeathEx",8000,0,"i",playerid);
  158. }
  159.  
  160. GetName(playerid)
  161. {
  162. new Name[MAX_PLAYER_NAME];
  163. GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  164. return Name;
  165. }
  166.  
  167. forward OnPlayerDeathEx(playerid);
  168. public OnPlayerDeathEx(playerid)
  169. {
  170. DestroyObject(pObject[playerid][0]);
  171. DestroyObject(pObject[playerid][1]);
  172. SetPlayerHealth(playerid,0);
  173. KillTimer(Timer[playerid]);
  174. return 1;
  175. }
  176.  
  177. OnPlayerUseRandomAnim(playerid)
  178. {
  179. new Random = random(4);
  180. switch(Random)
  181. {
  182. case 0:ApplyAnimation(playerid, "SWEET","Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0);
  183. case 1:ApplyAnimation(playerid, "KNIFE","KILL_Knife_Ped_Die",4.1,0,1,1,1,1);
  184. case 2:ApplyAnimation(playerid, "PED","KO_skid_front",4.1,0,1,1,1,0);
  185. case 3:ApplyAnimation(playerid, "PED","WALK_DRUNK",4.1,1,1,1,1,1);
  186. }
  187. }
  188.  
  189. OnPlayerDrunkLevel(playerid)
  190. {
  191. new Random = random(10);
  192. switch(Random)
  193. {
  194. case 0:SetPlayerDrunkLevel (playerid, 5000);
  195. case 1:SetPlayerDrunkLevel (playerid, 8000);
  196. case 2:SetPlayerDrunkLevel (playerid, 12000);
  197. case 3:SetPlayerDrunkLevel (playerid, 16000);
  198. case 4:SetPlayerDrunkLevel (playerid, 20000);
  199. case 5:SetPlayerDrunkLevel (playerid, 25000);
  200. case 6:SetPlayerDrunkLevel (playerid, 30000);
  201. case 7:SetPlayerDrunkLevel (playerid, 35000);
  202. case 8:SetPlayerDrunkLevel (playerid, 50000);
  203. case 9:SetPlayerDrunkLevel (playerid, 40000);
  204. }
  205. }
  206.  
  207. forward OnPlayerBombCountdown(playerid);
  208. public OnPlayerBombCountdown(playerid)
  209. {
  210. new Rstr[128];
  211. switch(CountDown[playerid])
  212. {
  213. case 1..10:
  214. {
  215. format(Rstr, sizeof(Rstr),"~y~Briefcase~n~~r~Exploding~n~In~n~~y~Time Left ~n~~b~%d",CountDown[playerid]);
  216. GameTextForPlayer(playerid,Rstr,1000,5);
  217. format(Rstr,sizeof(Rstr),"Bomb Exploding\nTime Left\n "COL_WHITE"%d",CountDown[playerid]);
  218. Update3DTextLabelText(BOMB_CD[playerid], COLOR_RED, Rstr);
  219. PlayerPlaySound(playerid, 4203, 0.0, 0.0, 0.0);
  220. }
  221. }
  222. CountDown[playerid]--;
  223. return 1;
  224. }
  225.  
  226. forward OnPlayerUseRemote(playerid);
  227. public OnPlayerUseRemote(playerid)
  228. {
  229. new count = 0,str[128];
  230. Bomb[playerid][0] = 0;
  231. BUTTON_PUSHED[playerid] = 0;
  232. CreateExplosion(Pos[playerid][0], Pos[playerid][1], Pos[playerid][2] , 12, 0.0);
  233. Delete3DTextLabel(BOMB_CD[playerid]);
  234. DestroyObject(BOMB_OBJECT[playerid]);
  235. KillTimer(EXPLODE_TIMER[playerid]);
  236. KillTimer(EXPLODE_BOMB[playerid]);
  237. foreach(Player, i)
  238. {
  239. if(IsPlayerInRangeOfPoint(i, RANGE, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]))
  240. {
  241. AppliedBombEffect(i);
  242. count++;
  243. }
  244. }
  245. if(count > 0)
  246. {
  247. new Random = RandomCash[random(5)];
  248. GivePlayerMoney(playerid,Random);
  249. format(str, sizeof(str), "[NEWS ALERT]:"COL_GREY" -| %d peoples are killed in the suicide remote bomb attack in San Andreas.|-",count );
  250. SCMToAll(COLOR_RED,str);
  251. }
  252. return 1;
  253. }
  254.  
  255. CMD:bombhelp(playerid,params[])
  256. {
  257. SCM(playerid, COLOR_GREEN, "[ BOMB HELP MENU ]");
  258. SCM(playerid, COLOR_GREEN, "Use /sbbomb [Range 1 - 30]");
  259. SCM(playerid, COLOR_GREEN, "Use /sjbomb [Range 1 - 30]");
  260. SCM(playerid, COLOR_GREEN, "Press Y key to use Suicide bomb.");
  261. SCM(playerid, COLOR_GREEN, "Use /cbomb [ To use suicide car bomb ]");
  262. SCM(playerid, COLOR_GREEN, "Press H key in car to blow car.");
  263. return 1;
  264. }
  265.  
  266. CMD:sbbomb(playerid,params[])
  267. {
  268. if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not allowed to use this bomb using any vehicle.");
  269. if(Bomb[playerid][1] == 1 || Bomb[playerid][2] == 1)return SCM(playerid,-1,"[SYSTEM] : You're already have bombs! You can't use this bomb at this moment.");
  270. if(Bomb[playerid][0])return SCM(playerid,-1,"[SYSTEM] : You're already have bomb.");
  271. if(sscanf(params,"d",RANGE))return SCM(playerid,COLOR_YELLOW,"/sbbomb [Range 1 - 30]");
  272. if(RANGE < 1 || RANGE > 30)return SCM(playerid,COLOR_YELLOW,"Range must between 1 to 30.");
  273. SetPlayerHoldingObject(playerid, 1210, 6,0.3,0.1,0,0,-90,0);
  274. Bomb[playerid][0] = 1;
  275. SCM(playerid, COLOR_GREEN, "You successfully got suicide bomb! Press Y key to use Suicide bomb.");
  276. return 1;
  277. }
  278.  
  279. CMD:sjbomb(playerid,params[])
  280. {
  281. if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not allowed to use this bomb using any vehicle.");
  282. if(Bomb[playerid][0] == 1 || Bomb[playerid][2] == 1)return SCM(playerid,-1,"[SYSTEM] : You're already have bombs! You can't use this bomb at this moment.");
  283. if(Bomb[playerid][1])return SCM(playerid,-1,"[SYSTEM] : You're already have bomb.");
  284. if(sscanf(params,"d",RANGE))return SCM(playerid,COLOR_YELLOW,"/sbomb [Range 1 - 30] ");
  285. if(RANGE < 1 || RANGE > 30)return SCM(playerid,COLOR_YELLOW,"Range must between 1 to 30.");
  286. SetPlayerAttachedObject(playerid,9, 19142, 1, 0.112397, 0.049958, -0.001576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000,0xFF00FF00);
  287. Bomb[playerid][1] = 1;
  288. SCM(playerid, COLOR_GREEN, "You successfully got suicide bomb! Press Y key to use Suicide bomb.");
  289. return 1;
  290. }
  291.  
  292. CMD:cbomb(playerid,params[])
  293. {
  294. if(!IsPlayerInAnyVehicle(playerid))return SCM(playerid,COLOR_YELLOW,"You're not in any vehicle.");
  295. if(Bomb[playerid][0] == 1 || Bomb[playerid][1] == 1)return SCM(playerid,-1,"[SYSTEM] : You're already have bombs! You can't use this bomb at this moment.");
  296. if(Bomb[playerid][2])return SCM(playerid,-1,"[SYSTEM] : You're already have bomb.");
  297. if(sscanf(params,"d",RANGE))return SCM(playerid,COLOR_YELLOW,"/cbomb [Range [1 - 30]");
  298. if(RANGE < 1 || RANGE > 30)return SCM(playerid,COLOR_YELLOW,"Range must between 1 to 30.");
  299. Bomb[playerid][2] = 1;
  300. SCM(playerid, COLOR_GREEN, "You successfully got suicide car bomb! Press H key in car to use Suicide car bomb.");
  301. return 1;
  302. }
Add Comment
Please, Sign In to add comment