Guest User

Untitled

a guest
Oct 19th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. /*
  2. Suicide Bomber Information Center:
  3.  
  4. The 'Suicide Bomber' idea came to me from a
  5. somewhat old mod that Exolent made (I've
  6. also made a version myself). Once you've
  7. gotten enough cash (cvar controlled), you
  8. will be permitted to purchase a 'Suicide Bomb'.
  9. You will then be able to activate it and blow
  10. anyone up in a certain radius of yourself,
  11. thus creating an epic death scene.
  12. */
  13.  
  14. #include <amxmodx>
  15. #include <hamsandwich>
  16. #include <engine>
  17. #include <cstrike>
  18.  
  19. #define PLUGIN "Suicide Bomb"
  20. #define AUTHOR "GXLZPGX"
  21. #define VERSION "1.4"
  22.  
  23. #define is_player(%1) (1 <= %1 <= g_iMaxPlayers)
  24. #define BOMB 100
  25.  
  26. /* Self explanitory private variables */
  27. new g_BombTimer[33];
  28.  
  29. /* Self explanitory private bools */
  30. new bool:g_HasBomb[33];
  31. new bool:g_BombRemoved[33];
  32.  
  33. /* Self explanitory public variables */
  34. new pcvar_BombEnable;
  35. new pcvar_BombPrice;
  36. new pcvar_BombRadius;
  37. new pcvar_BombFF;
  38.  
  39. /* Self explanitory public bools */
  40. new bool:g_RoundEnded;
  41.  
  42. /* Self explanitory sound path */
  43. new const gszC4[] = "weapons/c4_beep4.wav"
  44.  
  45. public plugin_init()
  46. {
  47. register_plugin(PLUGIN, VERSION, AUTHOR)
  48.  
  49. /* Player commands */
  50. register_clcmd( "say /buybomb", "Bomb_Buy" )
  51. register_clcmd( "say /bb", "Bomb_Buy" )
  52. register_clcmd( "say_team /buybomb", "Bomb_Buy" )
  53. register_clcmd( "say_team /bb", "Bomb_Buy" )
  54.  
  55. /* Server vars */
  56. pcvar_BombEnable = register_cvar( "sb_enabled", "1" )
  57. pcvar_BombPrice = register_cvar( "sb_price", "16000" )
  58. pcvar_BombRadius = register_cvar( "sb_radius", "400" )
  59. pcvar_BombFF = register_cvar( "sb_friendlyfire", "1" )
  60.  
  61. /* Hooking flashlight */
  62. register_impulse( 100, "Event_Flashlight" )
  63.  
  64. /* Round beginning */
  65. register_logevent( "Event_RoundBegin", 2, "1=Round_Start" );
  66.  
  67. /* Round ending */
  68. register_logevent( "Event_RoundEnd", 2, "1=Round_End" )
  69. }
  70.  
  71. public client_disconnect(id)
  72. {
  73. g_HasBomb[id] = false;
  74. }
  75.  
  76. public plugin_precache()
  77. {
  78. precache_sound( gszC4 )
  79. }
  80.  
  81. public Event_RoundEnd()
  82. {
  83. g_RoundEnded = true;
  84. }
  85.  
  86. public Event_RoundBegin()
  87. {
  88. g_RoundEnded = false;
  89.  
  90. arrayset( g_HasBomb, false, charsmax(g_HasBomb) )
  91. arrayset( g_BombRemoved, false, charsmax(g_BombRemoved) )
  92. }
  93.  
  94. public Bomb_Buy(id)
  95. {
  96. if( get_pcvar_num(pcvar_BombEnable) == 0 )
  97. {
  98. client_print( id, print_chat, "[Suicide Bomb] Suicide bombs are currently disabled." )
  99. return PLUGIN_HANDLED;
  100. }
  101.  
  102. new szBombMenu[104];
  103. formatex( szBombMenu, charsmax(szBombMenu), "\ySuicide Bomb Shop^n\rCurrent Price:\w %d^n^n\w Are you sure you want to buy a suicide bomb?", get_pcvar_num(pcvar_BombPrice) )
  104. new menu = menu_create( szBombMenu, "BombMenu_Handler" )
  105.  
  106. menu_additem( menu, "Yes", "1", 0 )
  107. menu_additem( menu, "No", "2", 0 )
  108.  
  109. menu_display( id, menu, 0 )
  110. menu_setprop( menu, MPROP_EXIT, MEXIT_ALL )
  111.  
  112. return PLUGIN_HANDLED
  113. }
  114.  
  115. public BombMenu_Handler(id, menu, item)
  116. {
  117. if( item == MENU_EXIT )
  118. {
  119. menu_destroy( menu );
  120. return PLUGIN_HANDLED;
  121. }
  122.  
  123. new data[6], iName[64];
  124. new access, callback;
  125. menu_item_getinfo( menu, item, access, data, 6, iName, 63, callback )
  126.  
  127. new key = str_to_num( data );
  128.  
  129. switch( key )
  130. {
  131. case 1:
  132. {
  133. new money = cs_get_user_money(id)
  134.  
  135. if( (money >= get_pcvar_num(pcvar_BombPrice)) && g_BombRemoved[id] == false )
  136. {
  137. cs_set_user_money( id, money - get_pcvar_num(pcvar_BombPrice) )
  138. client_print( id, print_chat, "[Suicide Bomb] You're now armed with a suicide bomb. Use your flashlight to activate it." )
  139. g_HasBomb[id] = true;
  140. g_BombRemoved[id] = true;
  141. } else {
  142. client_print( id, print_chat, "[Suicide Bomb] You're not permitted to use that, soldier!" )
  143. }
  144. }
  145. }
  146.  
  147. menu_destroy(menu);
  148. return PLUGIN_HANDLED;
  149. }
  150.  
  151. public Event_Flashlight(id)
  152. {
  153. if( !is_user_alive(id) )
  154. {
  155. return PLUGIN_HANDLED;
  156. }
  157.  
  158. if( g_HasBomb[id] == true && g_RoundEnded == false )
  159. {
  160. g_BombTimer[id] = 3;
  161.  
  162. if( task_exists( BOMB + id ) || g_BombTimer[id] < 3 )
  163. {
  164. return PLUGIN_HANDLED;
  165. }
  166.  
  167. set_task( 1.0, "CountDownExplode", BOMB + id, _, _, "b" )
  168. }
  169.  
  170. return PLUGIN_CONTINUE;
  171. }
  172.  
  173. public CountDownExplode(id)
  174. {
  175. id -= BOMB
  176.  
  177. if( !is_user_alive(id) || g_RoundEnded == true )
  178. {
  179. remove_task( id + BOMB )
  180. return PLUGIN_HANDLED;
  181. }
  182.  
  183. if( g_BombTimer[id] > 1 )
  184. {
  185. if( g_BombTimer[id] > 2 )
  186. {
  187. emit_sound(id, CHAN_AUTO, gszC4, 1.0, ATTN_NORM, 0, PITCH_NORM)
  188. }
  189.  
  190. g_BombTimer[id] -= 1
  191. } else {
  192. Explode(id)
  193.  
  194. new iPlayers[32], iNum, plr;
  195. get_players(iPlayers, iNum, "ah" )
  196.  
  197. new origin[3];
  198.  
  199. for( new i = 0; i < iNum; i++ )
  200. {
  201. plr = iPlayers[i]
  202.  
  203. new origin2[3];
  204.  
  205. get_user_origin( id, origin, 0 )
  206. get_user_origin( plr, origin2, 0 )
  207.  
  208. if( get_distance( origin, origin2 ) <= get_pcvar_num(pcvar_BombRadius) && is_user_alive(plr) )
  209. {
  210. if( get_pcvar_num(pcvar_BombFF) == 1 )
  211. {
  212. user_silentkill(plr)
  213.  
  214. Create_DeathMsg( plr, id )
  215. } else {
  216. if( (cs_get_user_team(id) != cs_get_user_team(plr)) )
  217. {
  218. user_silentkill(plr)
  219.  
  220. Create_DeathMsg( plr, id )
  221. }
  222. }
  223. }
  224. }
  225.  
  226. user_silentkill(id)
  227.  
  228. remove_task( id + BOMB )
  229. }
  230.  
  231. return PLUGIN_HANDLED;
  232. }
  233.  
  234. Explode(id)
  235. {
  236. new origin[3]
  237. get_user_origin(id, origin, 0)
  238.  
  239. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  240. write_byte(TE_TAREXPLOSION)
  241. write_coord(origin[0])
  242. write_coord(origin[1])
  243. write_coord(origin[2])
  244. message_end()
  245. }
  246.  
  247. public Create_DeathMsg( Victim, Attacker )
  248. {
  249. message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg"), {0,0,0});
  250. write_byte(Attacker);
  251. write_byte(Victim);
  252. write_byte(1)
  253. write_string("worldspawn");
  254. message_end();
  255. }
Add Comment
Please, Sign In to add comment