HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Forditas bY SmaCk
  2. *
  3. * Cut The Right Wire
  4. *
  5. * by The Specialist
  6. *
  7. * Idea : TinLab
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * In addition, as a special exception, the author gives permission to
  24. * link the code of this program with the Half-Life Game Engine ("HL
  25. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  26. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  27. * respects for all of the code used other than the HL Engine and MODs
  28. * from Valve. If you modify this file, you may extend this exception
  29. * to your version of the file, but you are not obligated to do so. If
  30. * you do not wish to do so, delete this exception statement from your
  31. * version.
  32. */
  33.  
  34. #include <amxmodx>
  35. #include <fakemeta>
  36.  
  37. #define TE_EXPLOSION 3
  38.  
  39. new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2 ;
  40. new g_Switch;
  41. new i;
  42. new PlayerDefused[33];
  43. new Sprite;
  44. new Float: Location[3];
  45. new wire;
  46. new g_AllTalk;
  47.  
  48. public plugin_init()
  49. {
  50. register_plugin("Cut The Right Wire","0.4","The Specialist");
  51. register_dictionary("right_wire.txt");
  52. register_menucmd(register_menuid("menu_show"),1023,"menu_choose");
  53. register_event("ResetHUD","wire_call","be");
  54. register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_Without_Kit");
  55. register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_With_Kit");
  56. register_forward(FM_PlayerPreThink,"block_buttons");
  57. }
  58. // detect defusing
  59. public bomb_defuse_no_kit()
  60. {
  61. new id = get_loguser_index();
  62.  
  63. if(get_pcvar_num(g_Switch)==0 || PlayerDefused[id] > 0 || is_user_bot(id)==1)
  64. {
  65. return PLUGIN_HANDLED;
  66. }else{
  67. new menu[192];
  68. format(menu,191,"%L",id,"CHOOSE");
  69. show_menu(id,keys,menu,-1,"menu_show");
  70. ++PlayerDefused[id];
  71. all_talk();
  72. ++i;
  73. return 0;
  74. }
  75. return 0;
  76. }
  77. // reset hud event
  78. public wire_call(id)
  79. {
  80. PlayerDefused[id] = 0;
  81. wire = random_num(0,1);
  82. }
  83. // remove use button and show menu
  84. public menu_choose(id,key)
  85. {
  86. switch(key)
  87. {
  88. case 0 :
  89. {
  90. if( wire == 0 )
  91. {
  92. --i;
  93. return PLUGIN_HANDLED;
  94. }else{
  95. bomb_explosion(id);
  96. PlayerDefused[id] = 0;
  97. return 1
  98. }
  99. }
  100. case 1:
  101. {
  102. if( wire == 1)
  103. {
  104. --i;
  105. return PLUGIN_HANDLED;
  106. }else{
  107. bomb_explosion(id);
  108. PlayerDefused[id] = 0;
  109. return 1
  110. }
  111. }
  112. }
  113. return PLUGIN_HANDLED;
  114. }
  115. // block the users use button
  116. public block_buttons(id)
  117. {
  118. if( i == 0 )
  119. {
  120. return 1;
  121. }else{
  122. set_pev( id, pev_button, pev(id,pev_button) & ~IN_USE);
  123. }
  124. return 1;
  125. }
  126. //bomb explosion
  127. public bomb_explosion(id)
  128. {
  129. pev(id, pev_origin,Location);
  130. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  131. write_byte(TE_EXPLOSION);
  132. engfunc(EngFunc_WriteCoord,Location[0]);
  133. engfunc(EngFunc_WriteCoord,Location[1]);
  134. engfunc(EngFunc_WriteCoord,Location[2]);
  135. write_short(Sprite);
  136. write_byte(255);
  137. write_byte(0);
  138. write_byte(0);
  139. message_end();
  140. user_silentkill(id);
  141. PlayerDefused[id] = 0;
  142. i = 0;
  143. return 1;
  144. }
  145. // turn all talk on
  146. public all_talk()
  147. {
  148. if(get_pcvar_num(g_AllTalk)==0)
  149. {
  150. return PLUGIN_HANDLED;
  151. }else{
  152. set_cvar_string("sv_alltalk","1");
  153. }
  154. return PLUGIN_HANDLED;
  155. }
  156. // function to get index from log events
  157. public get_loguser_index()
  158. {
  159. new loguser[80], name[32];
  160. read_logargv(0, loguser, 79);
  161. parse_loguser(loguser, name, 31);
  162. return get_user_index(name);
  163. }
  164. //precache sprites for exloasion
  165. public plugin_precache()
  166. {
  167. Sprite = precache_model("sprites/zerogxplode.spr");
  168. }
  169.  
  170.