HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. //==============================================================//
  2.  
  3. #include <amxmodx>
  4. #include <fakemeta>
  5. #include <hamsandwich>
  6.  
  7. #define IsPlayer(%1) (1<= %1 <= g_iMaxPlayers)
  8. new mode, hitchest, knife, bool:gBotsRegistered, g_iMaxPlayers;
  9.  
  10. public plugin_init()
  11. {
  12. register_plugin("Headshot Modes", "1.2", "=(GrG)= Doc Holiday");
  13. RegisterHam(Ham_TraceAttack, "player", "HamTraceAttack");
  14.  
  15. mode = register_cvar("nhs_mode", "2");
  16. hitchest = register_cvar("nhs_chest", "0");
  17. knife = register_cvar("nhs_knife", "1");
  18. g_iMaxPlayers = get_maxplayers();
  19. }
  20.  
  21. public client_authorized( id )
  22. {
  23. if( !gBotsRegistered && is_user_bot( id ) )
  24. {
  25. set_task( 0.1, "register_bots", id );
  26. }
  27. }
  28.  
  29. public register_bots( id )
  30. {
  31. if( !gBotsRegistered && is_user_connected( id ) )
  32. {
  33. RegisterHamFromEntity( Ham_TraceAttack, id, "HamTraceAttack");
  34. gBotsRegistered = true;
  35. }
  36. }
  37.  
  38. public HamTraceAttack(Vic, Att, Float:dmg, Float:dir[3], traceresult, dmgbits)
  39. {
  40.  
  41. if(!IsPlayer(Att) || !IsPlayer(Vic) || Vic == Att)
  42. return HAM_IGNORED;
  43.  
  44. if(get_pcvar_num(knife))
  45. {
  46. if( get_user_weapon( Att ) == CSW_KNIFE )
  47. return HAM_IGNORED;
  48. }
  49.  
  50. switch(get_pcvar_num(mode))
  51. {
  52. case 1: // Blocks bots from shooting humans in the head
  53. {
  54. if(!is_user_bot(Vic) && is_user_bot(Att))
  55. {
  56. if(get_pcvar_num(hitchest))
  57. {
  58. if(get_tr2(traceresult, TR_iHitgroup) == HIT_HEAD)
  59. {
  60. set_tr2(traceresult, TR_iHitgroup, HIT_CHEST)
  61. return HAM_HANDLED
  62. }
  63. }
  64. else
  65. {
  66. return HAM_SUPERCEDE
  67. }
  68. }
  69. }
  70. case 2: // Blocks all headshots (Humans and bots)
  71. {
  72. if(get_pcvar_num(hitchest))
  73. {
  74. if(get_tr2(traceresult, TR_iHitgroup) == HIT_HEAD)
  75. {
  76. set_tr2(traceresult, TR_iHitgroup, HIT_CHEST)
  77. return HAM_HANDLED
  78. }
  79. }
  80. else
  81. {
  82. return HAM_SUPERCEDE
  83. }
  84. }
  85. case 3: // Headshots Only (blocks all other hitzones)
  86. {
  87. if(get_tr2(traceresult, TR_iHitgroup) != HIT_HEAD)
  88. {
  89. return HAM_SUPERCEDE
  90. }
  91. }
  92. case 4:
  93. {
  94. if(get_tr2(traceresult, TR_iHitgroup) != HIT_HEAD)
  95. {
  96. set_tr2(traceresult, TR_iHitgroup, HIT_HEAD)
  97. return HAM_HANDLED
  98. }
  99. }
  100. }
  101. return HAM_IGNORED;
  102. }
  103.